diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-06 09:19:53 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-06 09:19:53 +0300 |
| commit | cd22de677cf942c8bf82c8bbb6e02ee5630076eb (patch) | |
| tree | 5fde4c94370c174e4aac3f06cf89dbb09e51b9a8 | |
| parent | 4fb8ff57dcd3bce39ac54d4c52cef091df8c570b (diff) | |
| download | Tango-cd22de677cf942c8bf82c8bbb6e02ee5630076eb.tar.gz Tango-cd22de677cf942c8bf82c8bbb6e02ee5630076eb.zip | |
Working on SQL Examiner Reports Loading..
25 files changed, 453 insertions, 61 deletions
diff --git a/Software/DB/Tango.mdf b/Software/DB/Tango.mdf Binary files differindex c7f3c97bc..36c0f2dc0 100644 --- a/Software/DB/Tango.mdf +++ b/Software/DB/Tango.mdf diff --git a/Software/DB/Tango_log.ldf b/Software/DB/Tango_log.ldf Binary files differindex 2733ed1d2..4d03056fb 100644 --- a/Software/DB/Tango_log.ldf +++ b/Software/DB/Tango_log.ldf 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<CompareDataRow> Rows { get; set; } + + public CompareData() + { + Rows = new List<CompareDataRow>(); + } + } +} 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<CompareDataRowField> Fields { get; set; } + + public CompareDataRow() + { + Fields = new List<CompareDataRowField>(); + } + } +} 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<CompareData> 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<ExaminerConfiguration> { [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<ExaminerDataReport> + { + [XmlAttribute("date")] + public String Date { get; set; } + + public List<ReportSource> Sources { get; set; } + + [XmlArray("Details")] + public List<CompareTotalItem> Totals { get; set; } + + [XmlArray("Objects")] + public List<CompareTable> Summary { get; set; } + + [XmlElement("Object")] + public List<CompareTable> Details { get; set; } + + public ExaminerDataReport() + { + Sources = new List<ReportSource>(); + Totals = new List<CompareTotalItem>(); + Summary = new List<CompareTable>(); + Details = new List<CompareTable>(); + } + } +} 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<ExaminerSchemaReport> + { + [XmlAttribute("date")] + public String Date { get; set; } + + public List<ReportSource> Sources { get; set; } + + public List<ReportDbObject> DbObjects { get; set; } + + public ExaminerSchemaReport() + { + Sources = new List<ReportSource>(); + DbObjects = new List<ReportDbObject>(); + } + } +} 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<T> 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<IncludeItem> Include { get; set; } + [XmlArray("Include")] + public List<IncludeItem> Includes { get; set; } public Filter() { - Include = new List<IncludeItem>(); + Includes = new List<IncludeItem>(); } } } 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<ReportLine> Lines { get; set; } + + public ReportDbObject() + { + Lines = new List<ReportLine>(); + } + } +} 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 Binary files differindex 1276c623e..066807077 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml +++ b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/OverrideData.xml diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml Binary files differindex 76b48e19a..c2e57e4db 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml +++ b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/ProvisionMachine.xml diff --git a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml Binary files differindex 5ec16cbe9..c399ec620 100644 --- a/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml +++ b/Software/Visual_Studio/Tango.SQLExaminer/SQLExaminer/Configurations/Schema.xml 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> SOItem { get; set; } + [XmlElement("SOItem")] + public List<SOItem> SOItems { get; set; } public SynchronizationOrder() { - SOItem = new List<SOItem>(); + SOItems = new List<SOItem>(); } } } 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 @@ <Compile Include="Action.cs" /> <Compile Include="AdditionalOption.cs" /> <Compile Include="Column.cs" /> + <Compile Include="CompareData.cs" /> + <Compile Include="CompareDataRow.cs" /> + <Compile Include="CompareDataRowField.cs" /> <Compile Include="ComparisonOption.cs" /> <Compile Include="DataSource.cs" /> + <Compile Include="CompareTable.cs" /> + <Compile Include="DbManager.cs" /> + <Compile Include="CompareTotalItem.cs" /> <Compile Include="ExaminerConfiguration.cs" /> <Compile Include="ExaminerConfigurationBuilder.cs" /> <Compile Include="ExaminerConfigurationType.cs" /> + <Compile Include="ExaminerDataReport.cs" /> <Compile Include="ExaminerProcess.cs" /> <Compile Include="ExaminerProcessExitCode.cs" /> <Compile Include="ExaminerProcessResult.cs" /> <Compile Include="ExaminerProcessType.cs" /> + <Compile Include="ExaminerSchemaReport.cs" /> + <Compile Include="ExaminerSerializedObject.cs" /> <Compile Include="Filter.cs" /> <Compile Include="Helper.cs" /> <Compile Include="IncludeItem.cs" /> @@ -66,6 +75,9 @@ <Compile Include="PerformanceOption.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Query.cs" /> + <Compile Include="ReportDbObject.cs" /> + <Compile Include="ReportLine.cs" /> + <Compile Include="ReportSource.cs" /> <Compile Include="SchemaMapping.cs" /> <Compile Include="SMItem.cs" /> <Compile Include="SOItem.cs" /> 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 @@ -82,23 +82,24 @@ namespace Tango.UnitTesting } [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); + } } } |
