diff --git a/SsisUnit.Tests/Commands/DataCompareCommandTest.cs b/SsisUnit.Tests/Commands/DataCompareCommandTest.cs new file mode 100644 index 0000000..77eb64e --- /dev/null +++ b/SsisUnit.Tests/Commands/DataCompareCommandTest.cs @@ -0,0 +1,90 @@ +using System; +using System.Data; + +using Microsoft.SqlServer.Dts.Runtime; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +using SsisUnit; +using SsisUnit.Enums; + +using SsisUnitBase.Enums; + +namespace UTssisUnit.Commands +{ + [TestClass] + public class DataCompareCommandTest : ExternalFileResourceTestBase + { + private string _dtsxFilePath; + + [TestInitialize] + public void Initialize() + { + _dtsxFilePath = UnpackToFile("UTssisUnit.TestPackages.SimplePackage.dtsx"); + } + + [TestMethod] + public void DataCompareCommandConstructorTest() + { + var target = new DataCompareCommand(new SsisTestSuite()); + Assert.IsNotNull(target); + } + + [TestMethod] + public void RunDataCompareCommandSetTest() + { + var ts = new SsisTestSuite(); + var connRef = new ConnectionRef("TestConn", "Data Source=localhost;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI", ConnectionRef.ConnectionTypeEnum.AdoNet, "System.Data.SqlClient"); + ts.ConnectionRefs.Add(connRef.ReferenceName, connRef); + var dataset = new Dataset( + ts, + "Test", + connRef, + false, + @"SELECT +CAST(1 AS INT) AS ColInt, +CAST('Test' AS VARCHAR(50)) AS ColVarChar, +CAST(N'Test' AS NVARCHAR(50)) AS ColNVarChar, +CAST('1900-01-01' AS DATETIME) AS ColDateTime"); + + var target = new DataCompareCommand(ts, "Test", dataset, dataset); + var actual = (DataCompareCommandResults) target.Execute(); + Assert.AreEqual(true, actual.IsDatasetsSame); + } + + [TestMethod] + public void RunDataCompareCommandSetWithOtherTestTest() + { + var ts = new SsisTestSuite(); + var connRef = new ConnectionRef("TestConn", "Data Source=localhost;Initial Catalog=AdventureWorks2012;Integrated Security=SSPI", ConnectionRef.ConnectionTypeEnum.AdoNet, "System.Data.SqlClient"); + var pkgRef = new PackageRef("pkg", _dtsxFilePath, PackageStorageType.FileSystem); + ts.ConnectionRefs.Add(connRef.ReferenceName, connRef); + ts.PackageRefs.Add(pkgRef.Name, pkgRef); + var dataset = new Dataset( + ts, + "Test", + connRef, + false, + @"SELECT +CAST(1 AS INT) AS ColInt, +CAST('Test' AS VARCHAR(50)) AS ColVarChar, +CAST(N'Test' AS NVARCHAR(50)) AS ColNVarChar, +CAST('1900-01-01' AS DATETIME) AS ColDateTime"); + ts.Datasets.Add(dataset.Name, dataset); + + var target = new DataCompareCommand(ts, "Test", dataset, dataset); + var test = new Test(ts, "TestCase1", "pkg", null, "\\Package"); + var assert = new SsisAssert(ts,test, "Assert1", true, false); + assert.Command = target; + test.Asserts.Add("Assert1", assert); + ts.Tests.Add("TestCase1", test); + var test2 = new Test(ts, "TestCase2", "pkg", null, "\\Package"); + var assert2 = new SsisAssert(ts, test2, "Assert2", false, false); + assert2.Command = new FileCommand(ts, "Exists", @"C:\Test\Test.pkg", string.Empty); + test2.Asserts.Add("Assert2", assert2); + ts.Tests.Add("TestCase2", test2); + + var actual = ts.Execute(); + Assert.AreEqual(4, ts.Statistics.GetStatistic(StatisticEnum.AssertPassedCount)); + } + } +} diff --git a/SsisUnit.Tests/DirectoryCommandTest.cs b/SsisUnit.Tests/Commands/DirectoryCommandTest.cs similarity index 95% rename from SsisUnit.Tests/DirectoryCommandTest.cs rename to SsisUnit.Tests/Commands/DirectoryCommandTest.cs index be0cd9c..f9fbadb 100644 --- a/SsisUnit.Tests/DirectoryCommandTest.cs +++ b/SsisUnit.Tests/Commands/DirectoryCommandTest.cs @@ -1,8 +1,10 @@ -using System; +using System; + using Microsoft.VisualStudio.TestTools.UnitTesting; + using SsisUnit; -namespace UTssisUnit +namespace UTssisUnit.Commands { /// /// This is a test class for DirectoryCommandTest and is intended diff --git a/SsisUnit.Tests/FileCommandTest.cs b/SsisUnit.Tests/Commands/FileCommandTest.cs similarity index 95% rename from SsisUnit.Tests/FileCommandTest.cs rename to SsisUnit.Tests/Commands/FileCommandTest.cs index b7dff85..b731d51 100644 --- a/SsisUnit.Tests/FileCommandTest.cs +++ b/SsisUnit.Tests/Commands/FileCommandTest.cs @@ -1,13 +1,12 @@ -using System; +using System; +using System.Text; using Microsoft.VisualStudio.TestTools.UnitTesting; using SsisUnit; -namespace UTssisUnit +namespace UTssisUnit.Commands { - using System.Text; - /// /// This is a test class for FileCommandTest and is intended /// to contain all FileCommandTest Unit Tests diff --git a/SsisUnit.Tests/ProcessCommandTest.cs b/SsisUnit.Tests/Commands/ProcessCommandTest.cs similarity index 93% rename from SsisUnit.Tests/ProcessCommandTest.cs rename to SsisUnit.Tests/Commands/ProcessCommandTest.cs index d5896d2..b2460a5 100644 --- a/SsisUnit.Tests/ProcessCommandTest.cs +++ b/SsisUnit.Tests/Commands/ProcessCommandTest.cs @@ -1,8 +1,8 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; +using Microsoft.VisualStudio.TestTools.UnitTesting; using SsisUnit; -namespace UTssisUnit +namespace UTssisUnit.Commands { /// /// This is a test class for ProcessCommandTest and is intended diff --git a/SsisUnit.Tests/PropertyCommandTest.cs b/SsisUnit.Tests/Commands/PropertyCommandTest.cs similarity index 97% rename from SsisUnit.Tests/PropertyCommandTest.cs rename to SsisUnit.Tests/Commands/PropertyCommandTest.cs index 0848ed8..0c2a97b 100644 --- a/SsisUnit.Tests/PropertyCommandTest.cs +++ b/SsisUnit.Tests/Commands/PropertyCommandTest.cs @@ -1,12 +1,12 @@ -using SsisUnit; -using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.SqlServer.Dts.Runtime; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SsisUnit; using SsisUnit.Enums; using SsisUnitBase.Enums; -namespace UTssisUnit +namespace UTssisUnit.Commands { [TestClass] public class PropertyCommandTest : ExternalFileResourceTestBase diff --git a/SsisUnit.Tests/SqlCommandTest.cs b/SsisUnit.Tests/Commands/SqlCommandTest.cs similarity index 96% rename from SsisUnit.Tests/SqlCommandTest.cs rename to SsisUnit.Tests/Commands/SqlCommandTest.cs index b03508f..53b0643 100644 --- a/SsisUnit.Tests/SqlCommandTest.cs +++ b/SsisUnit.Tests/Commands/SqlCommandTest.cs @@ -1,11 +1,12 @@ -using System.Diagnostics; +using System; +using System.Diagnostics; +using System.Xml; -using SsisUnit; using Microsoft.VisualStudio.TestTools.UnitTesting; -using System.Xml; -using System; -namespace UTssisUnit +using SsisUnit; + +namespace UTssisUnit.Commands { [TestClass] public class SqlCommandTest : ExternalFileResourceTestBase diff --git a/SsisUnit.Tests/SsisUnit2012.Tests.csproj b/SsisUnit.Tests/SsisUnit2012.Tests.csproj index ec74430..a458f72 100644 --- a/SsisUnit.Tests/SsisUnit2012.Tests.csproj +++ b/SsisUnit.Tests/SsisUnit2012.Tests.csproj @@ -80,14 +80,15 @@ - + + + + + + - - - -