diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
4 files changed, 147 insertions, 7 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs new file mode 100644 index 000000000..594c8d7f8 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/DataStore/DataStore_TST.cs @@ -0,0 +1,123 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR; +using Tango.PMR.Embroidery; +using Tango.DataStore; +using Tango.DataStore.Lite; +using Tango.Core.IO; +using Tango.DataStore.EF; +using Tango.PMR.Stubs; +using Tango.Transport; +using Tango.DataStore.Remote; + +namespace Tango.UnitTesting.DataStore +{ + [TestClass] + [TestCategory("DataStore")] + public class DataStore_TST + { + [TestMethod] + public void LiteDB_DataStore_Working() + { + var tempFile = TemporaryManager.Default.CreateImaginaryFile(); + Run_Test(new LiteDBDataStoreManager(tempFile)); + tempFile.Delete(); + } + + [TestMethod] + public void EF_DataStore_Working() + { + Run_Test(new EFDataStoreManager()); + } + + [TestMethod] + public void Remote_Data_Store_Working() + { + CalculateRequest calc = new CalculateRequest() + { + A = 10, + B = 15, + }; + + RemoteDataStoreGetResponse response = new RemoteDataStoreGetResponse(); + response.ProtoObject = DataStoreProtoObject.FromMessage(calc); + + byte[] data = GenericMessageSerializer.Serialize<RemoteDataStoreGetResponse>(response, PMR.Integration.GenericMessageProtocol.Bson); + + RemoteDataStoreGetResponse des = GenericMessageSerializer.Deserialize<RemoteDataStoreGetResponse>(data, PMR.Integration.GenericMessageProtocol.Bson); + + CalculateRequest cc = des.ProtoObject.Message as CalculateRequest; + + Assert.AreEqual<CalculateRequest>(calc, cc); + } + + private void Run_Test(IDataStoreManager manager) + { + IDataStoreCollection collection = manager.GetCollection("TEST"); + + { + collection.Put<int>("int", 10); + int value = collection.Get<int>("int"); + Assert.AreEqual<int>(value, 10); + } + + { + collection.Put<float>("float", 10f); + float value = collection.Get<float>("float"); + Assert.AreEqual<float>(value, 10f); + } + + { + collection.Put<double>("double", 10d); + double value = collection.Get<double>("double"); + Assert.AreEqual<double>(value, 10d); + } + + { + collection.Put<bool>("bool", true); + bool value = collection.Get<bool>("bool"); + Assert.AreEqual<bool>(value, true); + } + + { + collection.Put<string>("string", "some value"); + string value = collection.Get<string>("string"); + Assert.AreEqual<string>(value, "some value"); + } + + { + collection.Put<byte[]>("bytes", new byte[] { 255 }); + byte[] value = collection.Get<byte[]>("bytes"); + Assert.AreEqual<byte>(value[0], 255); + } + + { + collection.Put<CalculateRequest>("calc", new CalculateRequest() { A = 10, B = 15 }); + CalculateRequest value = collection.Get<CalculateRequest>("calc"); + Assert.AreEqual<CalculateRequest>(value, new CalculateRequest() { A = 10, B = 15 }); + } + + Assert.IsTrue(collection.Count() == 7); + + Assert.ThrowsException<NotSupportedException>(() => collection.Put<DataStore_TST>("somekey", this)); + + collection.Delete("int"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<int>("int")); + + collection.Delete("float"); + Assert.ThrowsException<KeyNotFoundException>(() => collection.Get<float>("float")); + + Assert.IsTrue(collection.Count() == 5); + + collection.DeleteAll(); + Assert.IsTrue(collection.Count() == 0); + + manager.Dispose(); + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs index 68232e512..651b46835 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs @@ -56,10 +56,7 @@ namespace Tango.UnitTesting.MachineService }).Result; //Should return setup information - var res5 = client.MachineSetup(new MachineSetupRequest() - { - SerialNumber = "0003", - }).GetAwaiter().GetResult(); + var res5 = client.MachineSetup(new MachineSetupRequest()).GetAwaiter().GetResult(); //Now get DEV data source using the machine studio client in order to validate the setup information. Tango.MachineStudio.Common.Web.MachineStudioWebClient msClient = new Tango.MachineStudio.Common.Web.MachineStudioWebClient(address, null); diff --git a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs index 0fdd437f0..948bc630b 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/RemoteRunner_TST.cs @@ -20,7 +20,7 @@ namespace Tango.UnitTesting { [TestClass] [TestCategory("Remote Runner")] - public class RemoteRunner_TST + public class RemoteRunner_TST { [TestMethod] public void Run_Remote_Runner_Connect_Upload_And_Execute_Process() @@ -80,7 +80,10 @@ namespace Tango.UnitTesting { UploadID = uploadResponse.UploadID, FileName = executeFileName, - }, TimeSpan.FromSeconds(30)).Result.Message; + }, new TransportRequestConfig() + { + Timeout = TimeSpan.FromSeconds(30), + }).Result.Message; Thread.Sleep(5000); diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 09799c0ed..b24079da0 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -138,6 +138,7 @@ <Compile Include="AdvancedInstaller\AdvancedInstaller_TST.cs" /> <Compile Include="BL\DTO_TST.cs" /> <Compile Include="BL\HardwareConfiguration_TST.cs" /> + <Compile Include="DataStore\DataStore_TST.cs" /> <Compile Include="Integration\JobDescriptionFile_TST.cs" /> <Compile Include="Logging\Parsing_TST.cs" /> <Compile Include="Logging\SessionLoging_TST.cs" /> @@ -212,6 +213,22 @@ <Project>{38197109-8610-4d3f-92b9-16d48df94d7c}</Project> <Name>Tango.DAL.Remote</Name> </ProjectReference> + <ProjectReference Include="..\Tango.DataStore.EF\Tango.DataStore.EF.csproj"> + <Project>{88d9906b-8fc4-4fe0-b7eb-127a0a8fcee4}</Project> + <Name>Tango.DataStore.EF</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore.LiteDB\Tango.DataStore.Lite.csproj"> + <Project>{fa96bc0c-4055-475c-9dcc-70a5a9436b10}</Project> + <Name>Tango.DataStore.Lite</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore.Remote\Tango.DataStore.Remote.csproj"> + <Project>{29448f3c-9b3e-4da6-8555-46a8b9a6b3aa}</Project> + <Name>Tango.DataStore.Remote</Name> + </ProjectReference> + <ProjectReference Include="..\Tango.DataStore\Tango.DataStore.csproj"> + <Project>{e0364dfa-0721-4637-9d32-9d22aac109d6}</Project> + <Name>Tango.DataStore</Name> + </ProjectReference> <ProjectReference Include="..\Tango.Documents\Tango.Documents.csproj"> <Project>{ca87a608-7b17-4c98-88f2-42abee10f4c1}</Project> <Name>Tango.Documents</Name> @@ -306,7 +323,7 @@ <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file |
