diff options
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Properties/AssemblyInfo.cs | 2 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs | 143 |
2 files changed, 134 insertions, 11 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Tango.UnitTesting/Properties/AssemblyInfo.cs index 6cb3427ef..2e78a70d1 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/Properties/AssemblyInfo.cs @@ -3,5 +3,5 @@ using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Tango - Unit Testing")] -[assembly: AssemblyVersion("2.0.5.1933")] +[assembly: AssemblyVersion("2.0.6.1537")] [assembly: ComVisible(false)]
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs index 32cd3eedb..8aa1fe5a3 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs @@ -7,6 +7,8 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; using Tango.Core.IO; using Tango.SQLExaminer; @@ -173,6 +175,9 @@ namespace Tango.UnitTesting public void Perform_Full_DataBase_Cycle() { String temp_folder = Helper.GetTempFolderPath(); + String report_file = Path.Combine(temp_folder, "report.xml"); + String config_file = Path.Combine(temp_folder, "config.xml"); + String machine_serial_number = "1111"; String tango_db = "Tango"; String source_db = "Source_DB_Test"; @@ -181,28 +186,146 @@ namespace Tango.UnitTesting DbManager db = new DbManager(new SqlConnection("Server=localhost\\SQLEXPRESS;Integrated security=SSPI")); Assert.IsTrue(db.Exists("Tango"), "Database Tango does not exists."); - Assert.IsFalse(db.Exists(source_db), source_db + " already exists."); - Assert.IsFalse(db.Exists(target_db), target_db + " already exists."); + if (db.Exists(source_db)) + { + db.Delete(source_db); + } + + if (db.Exists(target_db)) + { + db.Delete(target_db); + } - db.Create(source_db); + Assert.IsFalse(db.Exists(source_db), source_db + " exists."); + Assert.IsFalse(db.Exists(target_db), target_db + " exists."); + + //Clone Tango DB to SourceDB + db.CloneDB( + "Tango", + Path.Combine(temp_folder, "Tango.bak"), + source_db, + Path.Combine(temp_folder, "Source_DB_Test.mdf"), + Path.Combine(temp_folder, "Source_DB_Test.ldf")); + + //Create target database db.Create(target_db); + //Create schema configuration ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.Schema); builder. - SetSourceServer("localhost\\SQLEXPRESS", tango_db). - SetTargetServer("localhost\\SQLEXPRESS", source_db); + SetSourceServer("localhost\\SQLEXPRESS", source_db). + SetTargetServer("localhost\\SQLEXPRESS", target_db). + Synchronize(). + SetReportFile(report_file); - var config = builder.Build(); + //Synchronize Source schema with Target schema + ExaminerProcessResult result = new ExaminerProcess(builder.Build(), ExaminerProcessType.Schema).Execute().Result; - String config_path = Path.Combine(temp_folder, "schema.xml"); + var schema_report = ExaminerSchemaReport.FromFile(report_file); - config.ToFile(config_path); + //Synchronization was successful + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); - ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Schema); - var result = process.Execute().Result; + //Should have differences + Assert.IsTrue(schema_report.HasDifferences); + + //Create override data configuration + builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.OverrideData); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", source_db). + SetTargetServer("localhost\\SQLEXPRESS", target_db). + Synchronize(). + SetReportFile(report_file); + + result = new ExaminerProcess(builder.Build(), ExaminerProcessType.Data).Execute().Result; + + //Synchronization was successful + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + + var data_report = ExaminerDataReport.FromFile(report_file); + + //Should have differences + Assert.IsTrue(data_report.HasDifferences); + + //Provision Target + builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.ProvisionMachine); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", source_db). + SetTargetServer("localhost\\SQLEXPRESS", target_db). + SetMachineSerialNumber(machine_serial_number). + Synchronize(). + SetReportFile(report_file); + result = new ExaminerProcess(builder.Build(), ExaminerProcessType.Data).Execute().Result; + + //Synchronization was successful + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + + data_report = ExaminerDataReport.FromFile(report_file); + + //Should have differences + Assert.IsTrue(data_report.HasDifferences); + + //Check if machine exists in target + + String job_guid = String.Empty; + + using (var context = ObservablesContext.CreateDefault("localhost\\SQLEXPRESS", target_db)) + { + context.Configuration.LazyLoadingEnabled = false; + Assert.IsTrue(context.Machines.Count() == 1); + Assert.IsTrue(context.Machines.Any(x => x.SerialNumber == machine_serial_number)); + + //Add new job to the target + Job job = new Job(); + job.Name = "Test Job"; + job.Machine = context.Machines.First(); + job.Rml = context.Rmls.First(); + job.ColorSpace = context.ColorSpaces.First(); + job.CreationDate = DateTime.UtcNow; + job.Description = "Description"; + job.SpoolType = context.SpoolTypes.First(); + job.User = context.Users.First(); + job.WindingMethod = context.WindingMethods.First(); + job.AddSolidSegment(); + job.AddGradientSegment(); + + context.Jobs.Add(job); + + context.SaveChanges(); + + job_guid = job.Guid; + + Assert.IsTrue(context.BrushStops.Count() == 3); + } + + //Update new job from target to source + builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.UpdateTwineDB); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", target_db). + SetTargetServer("localhost\\SQLEXPRESS", source_db). + Synchronize(). + SetReportFile(report_file); + + result = new ExaminerProcess(builder.Build(), ExaminerProcessType.Data).Execute().Result; + + //Synchronization was successful Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + + data_report = ExaminerDataReport.FromFile(report_file); + + //Should have differences + Assert.IsTrue(data_report.HasDifferences); + + //Check the new job exists on source.. + using (var context = ObservablesContext.CreateDefault("localhost\\SQLEXPRESS", source_db)) + { + Assert.IsTrue(context.Jobs.Any(x => x.Guid == job_guid)); + } } } } |
