From cd22de677cf942c8bf82c8bbb6e02ee5630076eb Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Mon, 6 Aug 2018 09:19:53 +0300 Subject: Working on SQL Examiner Reports Loading.. --- .../Visual_Studio/Tango.SQLExaminer/CompareData.cs | 24 ++++++ .../Tango.SQLExaminer/CompareDataRow.cs | 21 +++++ .../Tango.SQLExaminer/CompareDataRowField.cs | 19 +++++ .../Tango.SQLExaminer/CompareTable.cs | 25 ++++++ .../Tango.SQLExaminer/CompareTotalItem.cs | 19 +++++ .../Visual_Studio/Tango.SQLExaminer/DbManager.cs | 85 +++++++++++++++++++++ .../Tango.SQLExaminer/ExaminerConfiguration.cs | 44 +---------- .../ExaminerConfigurationBuilder.cs | 2 +- .../Tango.SQLExaminer/ExaminerDataReport.cs | 35 +++++++++ .../Tango.SQLExaminer/ExaminerProcess.cs | 4 +- .../Tango.SQLExaminer/ExaminerSchemaReport.cs | 27 +++++++ .../Tango.SQLExaminer/ExaminerSerializedObject.cs | 55 +++++++++++++ Software/Visual_Studio/Tango.SQLExaminer/Filter.cs | 6 +- Software/Visual_Studio/Tango.SQLExaminer/Helper.cs | 2 +- .../Tango.SQLExaminer/ReportDbObject.cs | 30 ++++++++ .../Visual_Studio/Tango.SQLExaminer/ReportLine.cs | 20 +++++ .../Tango.SQLExaminer/ReportSource.cs | 22 ++++++ .../SQLExaminer/Configurations/OverrideData.xml | Bin 76070 -> 78756 bytes .../Configurations/ProvisionMachine.xml | Bin 58066 -> 58174 bytes .../SQLExaminer/Configurations/Schema.xml | Bin 6790 -> 6660 bytes .../Tango.SQLExaminer/SynchronizationOrder.cs | 6 +- .../Tango.SQLExaminer/Tango.SQLExaminer.csproj | 12 +++ .../Tango.UnitTesting/SQLExaminer_TST.cs | 56 +++++++++++--- 23 files changed, 453 insertions(+), 61 deletions(-) create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/CompareData.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/CompareDataRow.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/CompareDataRowField.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/CompareTable.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/CompareTotalItem.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/DbManager.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ExaminerDataReport.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ExaminerSchemaReport.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ReportDbObject.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ReportLine.cs create mode 100644 Software/Visual_Studio/Tango.SQLExaminer/ReportSource.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/Tango.SQLExaminer/CompareData.cs b/Software/Visual_Studio/Tango.SQLExaminer/CompareData.cs new file mode 100644 index 000000000..2339341d8 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/CompareData.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Data")] + public class CompareData + { + [XmlAttribute("status")] + public String Status { get; set; } + + [XmlElement("Row")] + public List Rows { get; set; } + + public CompareData() + { + Rows = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRow.cs b/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRow.cs new file mode 100644 index 000000000..23a4f190c --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRow.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Row")] + public class CompareDataRow + { + [XmlElement("Field")] + public List Fields { get; set; } + + public CompareDataRow() + { + Fields = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRowField.cs b/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRowField.cs new file mode 100644 index 000000000..a20393b38 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/CompareDataRowField.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Field")] + public class CompareDataRowField + { + [XmlElement("Value")] + public String SourceValue { get; set; } + + [XmlElement("Value2")] + public String TargetValue { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/CompareTable.cs b/Software/Visual_Studio/Tango.SQLExaminer/CompareTable.cs new file mode 100644 index 000000000..105287e1d --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/CompareTable.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Object")] + public class CompareTable + { + [XmlAttribute("type")] + public String Type { get; set; } + + [XmlAttribute("name")] + public String Name { get; set; } + + [XmlAttribute("state")] + public String State { get; set; } + + [XmlElement("")] + public List Data { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/CompareTotalItem.cs b/Software/Visual_Studio/Tango.SQLExaminer/CompareTotalItem.cs new file mode 100644 index 000000000..3637b4798 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/CompareTotalItem.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Item")] + public class CompareTotalItem + { + [XmlAttribute("status")] + public String Status { get; set; } + + [XmlText] + public String Count { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/DbManager.cs b/Software/Visual_Studio/Tango.SQLExaminer/DbManager.cs new file mode 100644 index 000000000..1407ba37f --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/DbManager.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.SQLExaminer +{ + public class DbManager + { + private SqlConnection _connection; + private bool _opened; + + public DbManager(SqlConnection connection) + { + _connection = connection; + } + + private void EnsureOpen() + { + if (!_opened) + { + _connection.Open(); + _opened = true; + } + } + + public void Create(String name) + { + EnsureOpen(); + String command = String.Format("CREATE DATABASE '{0}'", name); + SqlCommand cmd = new SqlCommand(command, _connection); + cmd.ExecuteNonQuery(); + } + + public bool Exists(String name) + { + try + { + EnsureOpen(); + String command = String.Format("SELECT database_id FROM sys.databases WHERE Name = '{0}'", name); + SqlCommand cmd = new SqlCommand(command, _connection); + object resultObj = cmd.ExecuteScalar(); + + int databaseID = 0; + + if (resultObj != null) + { + int.TryParse(resultObj.ToString(), out databaseID); + } + + return (databaseID > 0); + } + catch (Exception e) + { + return false; + } + } + + public void Delete(String name) + { + EnsureOpen(); + String command = String.Format("DROP DATABASE '{0}'", name); + SqlCommand cmd = new SqlCommand(command, _connection); + cmd.ExecuteNonQuery(); + } + + public void SetOffline(String name) + { + EnsureOpen(); + String command = String.Format("ALTER DATABASE '{0}' SET OFFLINE WITH ROLLBACK IMMEDIATE", name); + SqlCommand cmd = new SqlCommand(command, _connection); + cmd.ExecuteNonQuery(); + } + + public void SetOnline(String name) + { + EnsureOpen(); + String command = String.Format("ALTER DATABASE '{0}' SET ONLINE", name); + SqlCommand cmd = new SqlCommand(command, _connection); + cmd.ExecuteNonQuery(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfiguration.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfiguration.cs index 70a03e122..71d48d067 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfiguration.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfiguration.cs @@ -9,7 +9,7 @@ using System.Xml.Serialization; namespace Tango.SQLExaminer { [XmlRoot("config")] - public class ExaminerConfiguration + public class ExaminerConfiguration : ExaminerSerializedObject { [XmlAttribute("version")] public int Version { get; set; } @@ -37,47 +37,5 @@ namespace Tango.SQLExaminer Options = new Options(); Objects = new Objects(); } - - public static ExaminerConfiguration FromFile(String filePath) - { - return FromString(File.ReadAllText(filePath)); - } - - public static ExaminerConfiguration FromString(String xml) - { - XmlSerializer f = new XmlSerializer(typeof(ExaminerConfiguration), ""); - - ExaminerConfiguration config = null; - - using (var reader = new StringReader(xml)) - { - config = f.Deserialize(reader) as ExaminerConfiguration; - } - - return config; - } - - public void ToFile(String filePath) - { - File.WriteAllText(filePath, ToXml(), Encoding.Unicode); - } - - public String ToXml() - { - XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); - ns.Add("", ""); - - XmlSerializer f = new XmlSerializer(typeof(ExaminerConfiguration), ""); - - String result = String.Empty; - - using (var st = new StringWriter()) - { - f.Serialize(st, this, ns); - result = st.ToString(); - } - - return result; - } } } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfigurationBuilder.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfigurationBuilder.cs index e9116424c..bb1887877 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfigurationBuilder.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerConfigurationBuilder.cs @@ -99,7 +99,7 @@ namespace Tango.SQLExaminer Type = "report", Path = path, ReportType = "xml", - ReportOn = "Different, Same, OnlyInDb1, OnlyInDb2" + ReportOn = "Different, OnlyInDb1, OnlyInDb2" }); } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerDataReport.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerDataReport.cs new file mode 100644 index 000000000..333b31202 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerDataReport.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlRoot("VarianceReport")] + public class ExaminerDataReport : ExaminerSerializedObject + { + [XmlAttribute("date")] + public String Date { get; set; } + + public List Sources { get; set; } + + [XmlArray("Details")] + public List Totals { get; set; } + + [XmlArray("Objects")] + public List Summary { get; set; } + + [XmlElement("Object")] + public List Details { get; set; } + + public ExaminerDataReport() + { + Sources = new List(); + Totals = new List(); + Summary = new List(); + Details = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerProcess.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerProcess.cs index 5b4363c6e..8ec05c1e4 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerProcess.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerProcess.cs @@ -41,12 +41,12 @@ namespace Tango.SQLExaminer p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; - p.OutputDataReceived += (sender, args) => + p.OutputDataReceived += (sender, args) => { sb.AppendLine(args.Data); Progress?.Invoke(this, args.Data); }; - p.ErrorDataReceived += (sender, args) => + p.ErrorDataReceived += (sender, args) => { sb.AppendLine(args.Data); Progress?.Invoke(this, args.Data); diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSchemaReport.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSchemaReport.cs new file mode 100644 index 000000000..de983f692 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSchemaReport.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlRoot("VarianceReport")] + public class ExaminerSchemaReport : ExaminerSerializedObject + { + [XmlAttribute("date")] + public String Date { get; set; } + + public List Sources { get; set; } + + public List DbObjects { get; set; } + + public ExaminerSchemaReport() + { + Sources = new List(); + DbObjects = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs new file mode 100644 index 000000000..7416ee29a --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ExaminerSerializedObject.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + public abstract class ExaminerSerializedObject where T : class + { + public static T FromFile(String filePath) + { + return FromString(File.ReadAllText(filePath)); + } + + public static T FromString(String xml) + { + XmlSerializer f = new XmlSerializer(typeof(T), ""); + + T config = null; + + using (var reader = new StringReader(xml)) + { + config = f.Deserialize(reader) as T; + } + + return config; + } + + public void ToFile(String filePath) + { + File.WriteAllText(filePath, ToXml(), Encoding.Unicode); + } + + public String ToXml() + { + XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); + ns.Add("", ""); + + XmlSerializer f = new XmlSerializer(typeof(T), ""); + + String result = String.Empty; + + using (var st = new StringWriter()) + { + f.Serialize(st, this, ns); + result = st.ToString(); + } + + return result; + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/Filter.cs b/Software/Visual_Studio/Tango.SQLExaminer/Filter.cs index 373458139..f9b90adbc 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/Filter.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/Filter.cs @@ -3,16 +3,18 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Serialization; namespace Tango.SQLExaminer { public class Filter { - public List Include { get; set; } + [XmlArray("Include")] + public List Includes { get; set; } public Filter() { - Include = new List(); + Includes = new List(); } } } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/Helper.cs b/Software/Visual_Studio/Tango.SQLExaminer/Helper.cs index 3b4e238a7..5eb09b98c 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/Helper.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/Helper.cs @@ -8,7 +8,7 @@ using Tango.Core.Helpers; namespace Tango.SQLExaminer { - public static class Helper + internal static class Helper { public static String SQL_EXAMINER_FOLDER = Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), "SQLExaminer"); public static String SQL_EXAMINER_CONFIG_FOLDER = Path.Combine(SQL_EXAMINER_FOLDER, "Configurations"); diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ReportDbObject.cs b/Software/Visual_Studio/Tango.SQLExaminer/ReportDbObject.cs new file mode 100644 index 000000000..44e806e9e --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ReportDbObject.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("DbObject")] + public class ReportDbObject + { + [XmlAttribute("name")] + public String Name { get; set; } + + [XmlAttribute("type")] + public String Type { get; set; } + + [XmlAttribute("differIn")] + public String DifferIn { get; set; } + + [XmlElement("Line")] + public List Lines { get; set; } + + public ReportDbObject() + { + Lines = new List(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ReportLine.cs b/Software/Visual_Studio/Tango.SQLExaminer/ReportLine.cs new file mode 100644 index 000000000..43a9d2157 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ReportLine.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Line")] + public class ReportLine + { + [XmlAttribute("status")] + public String Status { get; set; } + + public String Left { get; set; } + + public String Right { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/ReportSource.cs b/Software/Visual_Studio/Tango.SQLExaminer/ReportSource.cs new file mode 100644 index 000000000..7fbe04f83 --- /dev/null +++ b/Software/Visual_Studio/Tango.SQLExaminer/ReportSource.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace Tango.SQLExaminer +{ + [XmlType("Source")] + public class ReportSource + { + [XmlAttribute("id")] + public String ID { get; set; } + + [XmlAttribute("type")] + public String Type { get; set; } + + [XmlAttribute("name")] + public String Name { get; set; } + } +} diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml index 1276c623e..066807077 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml index 76b48e19a..c2e57e4db 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml index 5ec16cbe9..c399ec620 100644 Binary files a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml and b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml differ diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SynchronizationOrder.cs b/Software/Visual_Studio/Tango.SQLExaminer/SynchronizationOrder.cs index 61ced00d8..fc16e2c34 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/SynchronizationOrder.cs +++ b/Software/Visual_Studio/Tango.SQLExaminer/SynchronizationOrder.cs @@ -12,12 +12,12 @@ namespace Tango.SQLExaminer [XmlAttribute("OnOperationLevel")] public String OnOperationLevel { get; set; } - [XmlElement("")] - public List SOItem { get; set; } + [XmlElement("SOItem")] + public List SOItems { get; set; } public SynchronizationOrder() { - SOItem = new List(); + SOItems = new List(); } } } diff --git a/Software/Visual_Studio/Tango.SQLExaminer/Tango.SQLExaminer.csproj b/Software/Visual_Studio/Tango.SQLExaminer/Tango.SQLExaminer.csproj index 0cdb6708b..716278e71 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/Tango.SQLExaminer.csproj +++ b/Software/Visual_Studio/Tango.SQLExaminer/Tango.SQLExaminer.csproj @@ -46,15 +46,24 @@ + + + + + + + + + @@ -66,6 +75,9 @@ + + + diff --git a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs index 84a81035b..32cd3eedb 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs @@ -81,24 +81,25 @@ namespace Tango.UnitTesting Helper.ShowInExplorer(config_path); } + [TestMethod] + public void LoadReport() + { + ExaminerDataReport report = ExaminerDataReport.FromFile("C:\\DATA\\report_data.xml"); + } + [TestMethod] public void Synchronize_Schema() { SqlConnection connection = new SqlConnection("Server=localhost\\SQLEXPRESS;Integrated security=SSPI"); - String command = @"CREATE DATABASE Test"; - - SqlCommand cmd = new SqlCommand(command, connection); - connection.Open(); - cmd.ExecuteNonQuery(); - ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.Schema); var temp_folder = Helper.GetTempFolderPath(); builder. SetSourceServer("localhost\\SQLEXPRESS", "Tango"). - SetTargetServer("localhost\\SQLEXPRESS", "Test"); + SetTargetServer("localhost\\SQLEXPRESS", "Test"). + SetReportFile("C:\\Data\\Report.xml"); var config = builder.Build(); @@ -121,7 +122,8 @@ namespace Tango.UnitTesting builder. SetSourceServer("localhost\\SQLEXPRESS", "Tango"). - SetTargetServer("localhost\\SQLEXPRESS", "Test"); + SetTargetServer("localhost\\SQLEXPRESS", "Test"). + SetReportFile("C:\\DATA\\report_data.xml"); var config = builder.Build(); @@ -130,7 +132,7 @@ namespace Tango.UnitTesting config.ToFile(config_path); ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Data); - process.Progress += (x, msg) => + process.Progress += (x, msg) => { Debug.WriteLine(msg); }; @@ -166,5 +168,41 @@ namespace Tango.UnitTesting Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); } + + [TestMethod] + public void Perform_Full_DataBase_Cycle() + { + String temp_folder = Helper.GetTempFolderPath(); + + String tango_db = "Tango"; + String source_db = "Source_DB_Test"; + String target_db = "Target_DB_Test"; + + 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."); + + db.Create(source_db); + db.Create(target_db); + + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.Schema); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", tango_db). + SetTargetServer("localhost\\SQLEXPRESS", source_db); + + var config = builder.Build(); + + String config_path = Path.Combine(temp_folder, "schema.xml"); + + config.ToFile(config_path); + + ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Schema); + var result = process.Execute().Result; + + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + } } } -- cgit v1.3.1