diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-04 11:49:31 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2018-08-04 11:49:31 +0300 |
| commit | 76d311ad4690b9f88ae71ff097c6592190b65012 (patch) | |
| tree | c4718bafe0bb6007a8fa76dd69a9b4fc05ffad81 /Software/Visual_Studio/Tango.UnitTesting | |
| parent | 40afcf1c6591abacfa1466dd4d865296bf687aa4 (diff) | |
| download | Tango-76d311ad4690b9f88ae71ff097c6592190b65012.tar.gz Tango-76d311ad4690b9f88ae71ff097c6592190b65012.zip | |
Implemented unit testing for SQLExaminer.
Diffstat (limited to 'Software/Visual_Studio/Tango.UnitTesting')
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs | 74 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj | 3 |
2 files changed, 72 insertions, 5 deletions
diff --git a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs index 3dd38c8e9..84a81035b 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs +++ b/Software/Visual_Studio/Tango.UnitTesting/SQLExaminer_TST.cs @@ -1,6 +1,8 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; using System.Collections.Generic; +using System.Data.SqlClient; +using System.Diagnostics; using System.IO; using System.Linq; using System.Text; @@ -82,15 +84,21 @@ namespace Tango.UnitTesting [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"). - SetBackupFile(Path.Combine(temp_folder, "db.bak")). - SetReportFile(Path.Combine(temp_folder, "report.xml")); + SetTargetServer("localhost\\SQLEXPRESS", "Test"); var config = builder.Build(); @@ -98,7 +106,65 @@ namespace Tango.UnitTesting config.ToFile(config_path); - Helper.ShowInExplorer(config_path); + ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Schema); + var result = process.Execute().Result; + + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + } + + [TestMethod] + public void Override_Data() + { + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.OverrideData); + + var temp_folder = Helper.GetTempFolderPath(); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", "Tango"). + SetTargetServer("localhost\\SQLEXPRESS", "Test"); + + var config = builder.Build(); + + String config_path = Path.Combine(temp_folder, "data.xml"); + + config.ToFile(config_path); + + ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + Debug.WriteLine(msg); + }; + var result = process.Execute().Result; + + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); + } + + [TestMethod] + public void Provision_Machine() + { + ExaminerConfigurationBuilder builder = new ExaminerConfigurationBuilder(ExaminerConfigurationType.ProvisionMachine); + + var temp_folder = Helper.GetTempFolderPath(); + + builder. + SetSourceServer("localhost\\SQLEXPRESS", "Tango"). + SetTargetServer("localhost\\SQLEXPRESS", "Test"). + SetMachineSerialNumber("1111"); + + var config = builder.Build(); + + String config_path = Path.Combine(temp_folder, "provision.xml"); + + config.ToFile(config_path); + + ExaminerProcess process = new ExaminerProcess(config_path, ExaminerProcessType.Data); + process.Progress += (x, msg) => + { + Debug.WriteLine(msg); + }; + var result = process.Execute().Result; + + Assert.AreEqual(result.ExitCode, ExaminerProcessExitCode.Success); } } } diff --git a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj index b5f1663b1..c2849f400 100644 --- a/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj +++ b/Software/Visual_Studio/Tango.UnitTesting/Tango.UnitTesting.csproj @@ -69,6 +69,7 @@ <Reference Include="System" /> <Reference Include="System.ComponentModel.DataAnnotations" /> <Reference Include="System.Core" /> + <Reference Include="System.Data" /> <Reference Include="System.Data.Entity.Design" /> <Reference Include="System.Data.SQLite, Version=1.0.108.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL"> <HintPath>..\packages\System.Data.SQLite.Core.1.0.108.0\lib\net46\System.Data.SQLite.dll</HintPath> @@ -201,7 +202,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 |
