diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-02-23 20:15:36 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2019-02-23 20:15:36 +0200 |
| commit | 17612c08da93c75d4c941a643bc7602c18f351d8 (patch) | |
| tree | 7fb879ef52d5460149b199f752279c3889cb5271 /Software/Visual_Studio/Tango.UnitTesting | |
| parent | d7c8a8e9a6320ade6098e0d8e182c7ada4e30a97 (diff) | |
| download | Tango-17612c08da93c75d4c941a643bc7602c18f351d8.tar.gz Tango-17612c08da93c75d4c941a643bc7602c18f351d8.zip | |
Implemented auto DTO generation.
Implemented mapping of DTO <=> Observables.
Organization of unit tests.
Removed DELETED from ADDRESS & CONTACT.
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
14 files changed, 71 insertions, 272 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs new file mode 100644 index 000000000..58a05ee83 --- /dev/null +++ b/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs @@ -0,0 +1,42 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Builders; +using Tango.BL.DTO; +using System.Data.Entity; +using DeepEqual.Syntax; + +namespace Tango.UnitTesting.BL +{ + [TestClass] + [TestCategory("BL - DTO")] + public class DTO_TST + { + /// <summary> + /// Creates the DTO from observable and map DTO to observable test. + /// </summary> + [TestMethod] + public void Create_DTO_From_Observable_and_Map_DTO_To_Observable() + { + using (ObservablesContext db = ObservablesContext.CreateDefault()) + { + var config = new ConfigurationBuilder(db).SetFirst().WithIdsPacks().Build(); + var configDTO = ConfigurationDTO.FromObservable(config); + + Assert.IsTrue(configDTO.Equals(config)); + + configDTO.MapToObservable(config); + + Assert.IsTrue(configDTO.Equals(config)); + + config = configDTO.ToObservable(); + + Assert.IsTrue(configDTO.Equals(config)); + } + } + } +} diff --git a/Software/Visual_Studio/Tango.UnitTesting/Temporary_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Core/TemporaryManager_TST.cs index 6e9d7eeb7..b017b4e11 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Temporary_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Core/TemporaryManager_TST.cs @@ -7,11 +7,11 @@ using System.Threading; using System.Threading.Tasks; using Tango.Core.IO; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.Core { [TestClass] [TestCategory("Temporary Files & Folders")] - public class Temporary_TST + public class TemporaryManager_TST { [TestMethod] public void Create_Temporary_Folder_And_Files_Display_And_Delete() diff --git a/Software/Visual_Studio/Tango.UnitTesting/Embroidery_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Embroidery/Embroidery_TST.cs index ccd71fdc8..cf72cd2c5 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Embroidery_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Embroidery/Embroidery_TST.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; using Tango.PMR; using Tango.PMR.Embroidery; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.Embroidery { [TestClass] [TestCategory("Embroidery")] diff --git a/Software/Visual_Studio/Tango.UnitTesting/Integration_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Integration/JobDescriptionFile_TST.cs index cbfc521bd..506d1dc94 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Integration_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Integration/JobDescriptionFile_TST.cs @@ -9,14 +9,14 @@ using Tango.Integration.Operation; using Tango.PMR.Printing; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.Integration { [TestClass] [TestCategory("Integration")] - public class Integration_TST + public class JobDescriptionFile_TST { [TestMethod] - public void _Write_Read_Validate_JobDescriptionFile() + public void Write_Read_Validate_JobDescriptionFile() { Random rnd = new Random(); diff --git a/Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs index c4a697715..57856f9cb 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Logging_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs @@ -7,11 +7,11 @@ using System.Threading.Tasks; using Tango.Integration.Logging; using Tango.Logging; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.Logging { [TestClass] [TestCategory("Logging")] - public class Logging_TST + public class Parsing_TST { [TestMethod] public void Parse_Application_Logs() diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs index 8a126df2e..56a57ab92 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/MachineStudio_Controller_TST.cs @@ -6,7 +6,7 @@ using Tango.MachineStudio.Common.Web; using Tango.Transport.Web; using System.Linq; -namespace Tango.UnitTesting.Web +namespace Tango.UnitTesting.MachineService { [TestClass] [TestCategory("Machine Service - Machine Studio")] 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 23ab74f3b..7c3d497b8 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineService/PPC_Controller_TST.cs @@ -7,7 +7,7 @@ using System.Linq; using Tango.PPC.Common.Web; using Tango.Core.IO; -namespace Tango.UnitTesting.Web +namespace Tango.UnitTesting.MachineService { [TestClass] [TestCategory("Machine Service - PPC")] @@ -62,8 +62,8 @@ namespace Tango.UnitTesting.Web }).GetAwaiter().GetResult(); //Now get DEV data source using the machine studio client in order to validate the setup information. - MachineStudio.Common.Web.MachineStudioWebClient msClient = new MachineStudio.Common.Web.MachineStudioWebClient(address, null); - var res6 = msClient.Login(new MachineStudio.Common.Web.LoginRequest() + Tango.MachineStudio.Common.Web.MachineStudioWebClient msClient = new Tango.MachineStudio.Common.Web.MachineStudioWebClient(address, null); + var res6 = msClient.Login(new Tango.MachineStudio.Common.Web.LoginRequest() { Email = "TestUser@twine-s.com", Password = "ASJH_asdjkl1234", diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs deleted file mode 100644 index 455a45895..000000000 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineService_TST.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Threading; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Tango.Transport.Web; -using Tango.Web.Authentication; - -namespace Tango.UnitTesting -{ - [TestClass] - [TestCategory("Machine Service")] - public class MachineService_TST - { - private class TokenObject : IEquatable<TokenObject> - { - public String Value { get; set; } - - public bool Equals(TokenObject other) - { - return Value == other.Value; - } - } - - [TestMethod] - public void Test_Tokens_Manager() - { - TokensManager<TokenObject> tokensManager = new TokensManager<TokenObject>(); - - TokenObject t1 = new TokenObject(); - t1.Value = "Roy"; - - TokenObject t2 = new TokenObject(); - t2.Value = "Sagi"; - - String token1 = tokensManager.GetOrCreate(t1).AccessToken; - String token2 = tokensManager.GetOrCreate(t2).AccessToken; - - Assert.AreEqual(tokensManager.GetTokenObject(token1), t1); - Assert.AreEqual(tokensManager.GetTokenObject(token2), t2); - - TokenObject t3 = new TokenObject(); - t3.Value = "Roy"; - - String token3 = tokensManager.GetOrCreate(t3).AccessToken; - Assert.AreEqual(token3, token1); - Assert.AreEqual(tokensManager.GetTokenObject(token1), tokensManager.GetTokenObject(token3)); - - TokenObject tOld = new TokenObject() - { - Value = "Expired Token" - }; - - tokensManager.ExpirationTime = TimeSpan.FromSeconds(2); - - Thread.Sleep(2000); - - String recent_token = tokensManager.GetOrCreate(tOld).AccessToken; - - Thread.Sleep(1000); - - tokensManager.Validate(recent_token); - - Assert.ThrowsException<TokenExpiredException>(() => tokensManager.Validate(token1)); - } - } -} diff --git a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio/MachineStudio_TST.cs index 827a41d80..b8c374d4f 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/MachineStudio_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/MachineStudio/MachineStudio_TST.cs @@ -14,7 +14,7 @@ using TestStack.White.UIItems.ListBoxItems; using TestStack.White.UIItems.WindowItems; using TestStack.White.WindowsAPI; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.MachineStudio { public static class AutomationExtensions { diff --git a/Software/Visual_Studio/Tango.UnitTesting/Protobuf_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Protobuf_TST.cs deleted file mode 100644 index bd95efb67..000000000 --- a/Software/Visual_Studio/Tango.UnitTesting/Protobuf_TST.cs +++ /dev/null @@ -1,132 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Tango.Protobuf; -using System.Threading; -using System.Collections.Generic; -using System.Linq; -using System.IO; -using Google.Protobuf; -using Tango.PMR.Printing; -using Tango.PMR.Common; -using Tango.PMR; -using Tango.Logging; -using Newtonsoft.Json; -using System.Runtime.InteropServices; -using Tango.Core.Helpers; -using System.Text; -using Tango.PMR.Stubs; - -namespace Tango.UnitTesting -{ - [TestClass] - [TestCategory("Protobuf")] - public class Protobuf_TST - { - [DllImport("Tango.ProtoTest.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Calculate")] - public static extern int CalculateCPP(IntPtr data, int size, ref IntPtr output); - - [DllImport("Tango.ColorLib.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "Calculate")] - public static extern int CalculateC(IntPtr data, int size, ref IntPtr output); - - /// <summary> - /// Compiles all the whole PMR using all available compilers. - /// </summary> - [TestMethod] - public void Compile_All_PMR() - { - var console = Helper.InitializeLogging(true); - - String pmrFolder = Helper.GetPMRPath(); - - List<String> tempFolders = new List<string>(); - - foreach (var compiler in CompilerFactory.GetAvailableCompilers()) - { - CompilerFolderResult result = compiler.CompileFolder(pmrFolder); - String tmpFolder = Helper.GetTempFolderPathAppend(compiler.Language.ToString()); - result.Save(tmpFolder); - tempFolders.Add(tmpFolder); - } - - Helper.ShowInExplorer(Directory.GetParent(tempFolders.First()).FullName); - - console.WaitForConsoleExit().Wait(); - - foreach (var folder in tempFolders) - { - Helper.TryDeleteFolder(folder); - } - } - - /// <summary> - /// Writes and reads a proto message then compares. - /// </summary> - [TestMethod] - public void Read_Write_Message() - { - var console = Helper.InitializeLogging(true); - - TangoMessage<JobTicket> container = MessageFactory.CreateTangoMessage<JobTicket>(); - - container.Message.Name = "Test Job"; - - container.Message.Segments.Add(new JobSegment() - { - Length = 10, - Name = "Segment 1" - }); - - container.Message.Segments.Add(new JobSegment() - { - Length = 100, - Name = "Segment 2" - }); - - LogManager.Default.Log("Write Message:" + Environment.NewLine + JsonConvert.SerializeObject(container.Message, Formatting.Indented)); - - var bytes = container.ToBytes(); - - var parsed = MessageFactory.ParseTangoMessage<JobTicket>(bytes); - - LogManager.Default.Log("Read Message:" + Environment.NewLine + JsonConvert.SerializeObject(parsed.Message, Formatting.Indented)); - - Assert.AreEqual(container.Message, parsed.Message); - - LogManager.Default.Log("Test Passed!"); - - console.WaitForConsoleExit().Wait(); - } - - /// <summary> - /// Calls a C++ native library using protobuf and gets a result. - /// </summary> - [TestMethod] - public void Call_CPP_And_Get_Result() - { - CalculateRequest request = new CalculateRequest(); - request.A = 10; - request.B = 5; - - NativePMR<CalculateRequest, CalculateResponse> nativePMR = new NativePMR<CalculateRequest, CalculateResponse>(CalculateCPP); - CalculateResponse response = nativePMR.Invoke(request); - - Assert.AreEqual(response.Sum, request.A + request.B); - } - - /// <summary> - /// Calls a C++ native library using protobuf and gets a result. - /// </summary> - [TestMethod] - public void Call_C_And_Get_Result() - { - CalculateRequest request = new CalculateRequest(); - request.A = 10; - request.B = 5; - - NativePMR<CalculateRequest, CalculateResponse> nativePMR = new NativePMR<CalculateRequest, CalculateResponse>(CalculateC); - CalculateResponse response = nativePMR.Invoke(request); - - Assert.AreEqual(response.Sum, request.A + request.B); - } - } -} diff --git a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs index e914c0807..9b0385c23 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs @@ -14,15 +14,15 @@ using Tango.Core.DB; using Tango.Core.IO; using Tango.SQLExaminer; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.SQLExaminer { [TestClass] [TestCategory("SQL Examiner")] public class SQLExaminer_TST { - private Core.DataSource GetSource(String catalog = "Tango") + private Tango.Core.DataSource GetSource(String catalog = "Tango") { - return new Core.DataSource() + return new Tango.Core.DataSource() { Type = DataSourceType.SQLServer, Address = "localhost\\SQLEXPRESS", @@ -31,9 +31,9 @@ namespace Tango.UnitTesting }; } - private Core.DataSource GetTarget(String catalog = "Test") + private Tango.Core.DataSource GetTarget(String catalog = "Test") { - return new Core.DataSource() + return new Tango.Core.DataSource() { Type = DataSourceType.SQLServer, Address = "localhost\\SQLEXPRESS", diff --git a/Software/Visual_Studio/Tango.UnitTesting/Scripting_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Scripting_TST.cs deleted file mode 100644 index e574e304e..000000000 --- a/Software/Visual_Studio/Tango.UnitTesting/Scripting_TST.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using Microsoft.VisualStudio.TestTools.UnitTesting; -using Tango.DAL.Remote.DB; -using Tango.BL.Entities; -using Tango.Settings; -using System.Linq; -using System.Collections.Generic; -using Tango.DBObservablesGenerator.CLI; -using Tango.Scripting; - -namespace Tango.UnitTesting -{ - [TestClass] - [TestCategory("Scripting")] - public class Scripting_TST - { - [TestMethod] - public void Parse_CSharp_Code() - { - String code = @"using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Scripting -{ - public void Do(int a, int b) -{ - -MyType type = new MyType(); - -type.number = 10; - - -} -}"; - - - ScriptParser parser = new ScriptParser(); - parser.ParseScript(code); - - } - } -} diff --git a/Software/Visual_Studio/Tango.UnitTesting/TFS_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/TFS/TFS_TST.cs index 47984792a..613cfb8c5 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/TFS_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/TFS/TFS_TST.cs @@ -9,7 +9,7 @@ using Tango.Core.Helpers; using Tango.Core.IO; using Tango.TFS; -namespace Tango.UnitTesting +namespace Tango.UnitTesting.TFS { [TestClass] [TestCategory("Team Foundation Service")] diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index 445992b64..833e21330 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -99,21 +99,19 @@ <Compile Include="..\Versioning\GlobalVersionInfo.cs"> <Link>GlobalVersionInfo.cs</Link> </Compile> - <Compile Include="Integration_TST.cs" /> - <Compile Include="Logging_TST.cs" /> + <Compile Include="BL\DTO_TST.cs" /> + <Compile Include="Integration\JobDescriptionFile_TST.cs" /> + <Compile Include="Logging\Parsing_TST.cs" /> <Compile Include="MachineService\PPC_Controller_TST.cs" /> - <Compile Include="MachineStudio_TST.cs" /> + <Compile Include="MachineStudio\MachineStudio_TST.cs" /> <Compile Include="RemoteRunner_TST.cs" /> - <Compile Include="SQLExaminer_TST.cs" /> - <Compile Include="Temporary_TST.cs" /> - <Compile Include="TFS_TST.cs" /> + <Compile Include="SQLExaminer\SQLExaminer_TST.cs" /> + <Compile Include="Core\TemporaryManager_TST.cs" /> + <Compile Include="TFS\TFS_TST.cs" /> <Compile Include="Outlook_TST.cs" /> - <Compile Include="Scripting_TST.cs" /> - <Compile Include="Embroidery_TST.cs" /> + <Compile Include="Embroidery\Embroidery_TST.cs" /> <Compile Include="Helper.cs" /> - <Compile Include="Protobuf_TST.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="MachineService_TST.cs" /> <Compile Include="Web\JWT_Tokens_TST.cs" /> <Compile Include="MachineService\MachineStudio_Controller_TST.cs" /> </ItemGroup> @@ -211,6 +209,7 @@ <Name>Tango.DBObservablesGenerator.CLI</Name> </ProjectReference> </ItemGroup> + <ItemGroup /> <Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> @@ -225,7 +224,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 |
