aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.UnitTesting
diff options
context:
space:
mode:
authorShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
committerShlomo Hecht <shlomo@twine-s.com>2020-01-27 09:19:11 +0200
commitddda6089bff56e80703c8d2dce297919edc58bf1 (patch)
tree7702c5cf169124d522eacc7f1a9e0878373baedd /Software/Visual_Studio/Tango.UnitTesting
parent1d4d327571d4c0c9f4e17411551bd4dae1e2aed0 (diff)
parentbf2f3245339b9fd9148a2ad25b5ba3320e970cc1 (diff)
downloadTango-ddda6089bff56e80703c8d2dce297919edc58bf1.tar.gz
Tango-ddda6089bff56e80703c8d2dce297919edc58bf1.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/Tango/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/App.config4
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs12
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs22
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Logging/SessionLoging_TST.cs38
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs71
-rw-r--r--Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj3
6 files changed, 149 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/App.config b/Software/Visual_Studio/Tango.UnitTesting/App.config
index 0490d020e..0641554af 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/App.config
+++ b/Software/Visual_Studio/Tango.UnitTesting/App.config
@@ -121,6 +121,10 @@
<assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.2" newVersion="4.1.1.2" />
</dependentAssembly>
+ <dependentAssembly>
+ <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
+ <bindingRedirect oldVersion="0.0.0.0-4.0.1.0" newVersion="4.0.1.0" />
+ </dependentAssembly>
</assemblyBinding>
</runtime>
<system.data>
diff --git a/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs
index 58a05ee83..a574f7ea0 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/BL/DTO_TST.cs
@@ -38,5 +38,17 @@ namespace Tango.UnitTesting.BL
Assert.IsTrue(configDTO.Equals(config));
}
}
+
+ [TestMethod]
+ public void DTOPropertyAttribute_Is_Working()
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var hwBlower = db.HardwareBlowers.Include(x => x.HardwareBlowerType).First();
+ var dto = HardwareBlowerDTO.FromObservable(hwBlower);
+
+ Assert.AreEqual(dto.HardwareBlowerTypeDescription, hwBlower.HardwareBlowerType.Description);
+ }
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs
index 57856f9cb..8cc87e700 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/Logging/Parsing_TST.cs
@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using Tango.Integration.Logging;
using Tango.Logging;
@@ -30,5 +31,26 @@ namespace Tango.UnitTesting.Logging
var logFile = logFiles.OrderByDescending(x => x.DateTime).First();
var logs = parser.Parse(logFile);
}
+
+ [TestMethod]
+ public void Parse_Multi_Part_Log_Files()
+ {
+ var manager = LogManager.Default;
+ var fileLogger = new FileLogger();
+ var folder = FileLogger.DefaultLogsFolder;
+ fileLogger.EnableMaxFileSizeLimit = true;
+ fileLogger.MaxFileSizeLimit = 10000;
+ LogManager.Default.RegisterLogger(fileLogger);
+ for (int i = 0; i < 100; i++)
+ {
+ manager.Log($"This is a test {i}");
+ Thread.Sleep(100);
+ }
+ Thread.Sleep(1000);
+ ApplicationLogFileParser parser = new ApplicationLogFileParser();
+ var logFiles = parser.GetLogFiles();
+ var logFile = logFiles.OrderByDescending(x => x.DateTime).First();
+ var logs = parser.Parse(logFile);
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Logging/SessionLoging_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/Logging/SessionLoging_TST.cs
new file mode 100644
index 000000000..873fcca57
--- /dev/null
+++ b/Software/Visual_Studio/Tango.UnitTesting/Logging/SessionLoging_TST.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using Tango.Logging;
+
+namespace Tango.UnitTesting.Logging
+{
+ [TestClass]
+ [TestCategory("Logging")]
+ public class SessionLoging_TST
+ {
+ [TestMethod]
+ public void Create_Session_File_Logger()
+ {
+ SessionFileLogger sessionlogger = new SessionFileLogger();
+ LogManager.Default.RegisterLogger(sessionlogger);
+ sessionlogger.CreateSession();
+ var manager = LogManager.Default;
+
+ manager.Log($"This is a test 1");
+ Thread.Sleep(300);
+ SessionFileLogger slogger = LogManager.Default.RegisteredLoggers.FirstOrDefault(x => x.GetType() == typeof(SessionFileLogger)) as SessionFileLogger;
+ string[] fileEntries = Directory.GetFiles(slogger.Folder, "*.log");
+ Assert.AreEqual(1, fileEntries.Count());
+
+ sessionlogger.CreateSession();
+ manager.Log($"This is a test 2");
+ Thread.Sleep(300);
+ fileEntries = Directory.GetFiles(slogger.Folder, "*.log");
+ Assert.AreEqual(1, fileEntries.Count());
+ }
+ }
+}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs
index 9b0385c23..e3e49ac5e 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs
+++ b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer/SQLExaminer_TST.cs
@@ -391,5 +391,76 @@ namespace Tango.UnitTesting.SQLExaminer
//Should have no differences!
Assert.IsFalse(data_report.HasDifferences);
}
+
+ [TestMethod]
+ public void Perform_Machine_Update_From_Backup()
+ {
+ String tempDbName = "Tango_TUP";
+
+ var source_db = GetSource("Tango");
+ var target_db = GetSource(tempDbName);
+
+ DbManager dbManager = DbManager.FromDataSource(source_db);
+
+ //Create the backup for the tup file.
+ dbManager.Create(tempDbName);
+
+ var configuration = GetFullConfiguration();
+
+ ExaminerSequenceConfigurationRunner runner =
+ new ExaminerSequenceConfigurationRunner(
+ configuration,
+ Tango.SQLExaminer.Helper.SQL_EXAMINER_CONFIG_FOLDER,
+ source_db,
+ target_db,
+ "1111");
+
+ runner.Run().GetAwaiter().GetResult();
+
+ String backupFile = "C:\\DB_Backups\\Tango_TEMP.bak";
+
+ dbManager.Backup(tempDbName, backupFile);
+ dbManager.SetOffline(tempDbName);
+ dbManager.SetOnline(tempDbName);
+ dbManager.Delete(tempDbName);
+
+ //Now restore as different name
+ dbManager.RestoreAsNew(tempDbName, backupFile, "C:\\DB_Backups");
+ }
+
+ private ExaminerSequenceConfiguration GetFullConfiguration()
+ {
+ ExaminerSequenceConfiguration configuration = new ExaminerSequenceConfiguration();
+
+ configuration.Items.Add(new ExaminerSequenceItem()
+ {
+ Type = ExaminerSequenceItemType.Schema,
+ Direction = ExaminerSequenceItemDirection.SourceToTarget,
+ FileName = ExaminerConfigurationType.Schema.GetFileName(),
+ Index = 0,
+ Name = "Updating Schema",
+ });
+
+ configuration.Items.Add(new ExaminerSequenceItem()
+ {
+ Type = ExaminerSequenceItemType.Data,
+ Direction = ExaminerSequenceItemDirection.SourceToTarget,
+ FileName = ExaminerConfigurationType.OverrideData.GetFileName(),
+ Index = 1,
+ Name = "Updating Collections",
+ });
+
+ configuration.Items.Add(new ExaminerSequenceItem()
+ {
+ Type = ExaminerSequenceItemType.Data,
+ Direction = ExaminerSequenceItemDirection.SourceToTarget,
+ FileName = ExaminerConfigurationType.ProvisionMachine.GetFileName(),
+ Index = 2,
+ Name = "Configuring Machine",
+ RequiresSerialNumber = true,
+ });
+
+ return configuration;
+ }
}
}
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
index 05daac6c7..01e639a75 100644
--- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
+++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj
@@ -140,6 +140,7 @@
<Compile Include="BL\HardwareConfiguration_TST.cs" />
<Compile Include="Integration\JobDescriptionFile_TST.cs" />
<Compile Include="Logging\Parsing_TST.cs" />
+ <Compile Include="Logging\SessionLoging_TST.cs" />
<Compile Include="MachineService\PPC_Controller_TST.cs" />
<Compile Include="MachineStudio\MachineStudio_TST.cs" />
<Compile Include="Pulse\Pulse_TST.cs" />
@@ -309,7 +310,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