Skip to content

Commit

Permalink
Reorg, added test for data compare
Browse files Browse the repository at this point in the history
  • Loading branch information
johnwelch committed Oct 28, 2013
1 parent d4eabed commit c7cfedc
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 21 deletions.
90 changes: 90 additions & 0 deletions 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));
}
}
}
@@ -1,8 +1,10 @@
using System;
using System;

using Microsoft.VisualStudio.TestTools.UnitTesting;

using SsisUnit;

namespace UTssisUnit
namespace UTssisUnit.Commands
{
/// <summary>
/// This is a test class for DirectoryCommandTest and is intended
Expand Down
@@ -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;

/// <summary>
/// This is a test class for FileCommandTest and is intended
/// to contain all FileCommandTest Unit Tests
Expand Down
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;

using SsisUnit;

namespace UTssisUnit
namespace UTssisUnit.Commands
{
/// <summary>
/// This is a test class for ProcessCommandTest and is intended
Expand Down
@@ -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
Expand Down
@@ -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
Expand Down
11 changes: 6 additions & 5 deletions SsisUnit.Tests/SsisUnit2012.Tests.csproj
Expand Up @@ -80,14 +80,15 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="DirectoryCommandTest.cs" />
<Compile Include="Commands\DataCompareCommandTest.cs" />
<Compile Include="Commands\DirectoryCommandTest.cs" />
<Compile Include="Commands\FileCommandTest.cs" />
<Compile Include="Commands\ProcessCommandTest.cs" />
<Compile Include="Commands\PropertyCommandTest.cs" />
<Compile Include="Commands\SqlCommandTest.cs" />
<Compile Include="ExternalFileResourceTestBase.cs" />
<Compile Include="FileCommandTest.cs" />
<Compile Include="PackageRefTest.cs" />
<Compile Include="ProcessCommandTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyCommandTest.cs" />
<Compile Include="SqlCommandTest.cs" />
<Compile Include="SsisAssertTest.cs" />
<Compile Include="SSISTestCaseTest.cs" />
<Compile Include="ssisUnit_UTHelper.cs" />
Expand Down

0 comments on commit c7cfedc

Please sign in to comment.