protected override void Setup(SetupContext context) { DtsParameter param = context.Package.GetParameter("SourcePath"); object val = param.GetValue(); param.SetValue(Constants.CustomersFileSource); DtsVariable var1 = context.Package.GetVariable("DestinationPath"); var1.SetValue(Constants.CustomersFileDestination); DtsVariable var2 = context.Package.GetVariable("ConvertDestinationPath"); var2.SetValue(Constants.CustomersFileConverted); DtsVariable var3 = context.Package.GetVariable("CopyCustomersPath"); var3.SetValue(Constants.PathToCopyCustomersPackage); DtsVariable var4 = context.Package.GetVariable("LoadCustomersPath"); var4.SetValue(Constants.PathToLoadCustomersPackage); DtsVariable var5 = context.Package.GetVariable("ConnectionString"); var5.SetValue(Constants.SsisDbConnectionString); }
protected override void Setup(SetupContext context) { DtsVariable custSrc = context.Package.GetVariableForPath(@"\[CopyCustomers4].[SourcePath]"); custSrc.SetValue(Constants.CustomersFileSource); DtsVariable custDest = context.Package.GetVariableForPath(@"\[CopyCustomers4].[DestinationPath]"); custDest.SetValue(Constants.CustomersFileDestination); DtsVariable custDestNew = context.Package.GetVariableForPath(@"\[CopyCustomers4].[ConvertDestinationPath]"); custDestNew.SetValue(Constants.CustomersFileConverted); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers4]\[DFT Convert customer names].[CustomerCount]"); variable.SetValue(0); DtsConnection newCustomersConnection = context.Package.GetConnection("New Customers Src"); newCustomersConnection.SetConnectionString(Constants.CustomersNewFileSource); DtsConnection productConnection = context.Package.GetConnection("Products Src"); productConnection.SetConnectionString(Constants.ProductsFileSource); }
protected override void Verify(VerificationContext context) { context.Package.ThrowExceptionOnError(); Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, exists); DtsVariable customerCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers4]\[DFT Convert customer names].[CustomerCount]"); var customersCount = (int)customerCountVariable.GetValue(); Assert.AreEqual(13, customersCount); DtsVariable sourceCustomersErrorCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers4]\[DFT Convert customer names].[SourceCustomersErrorCount]"); var errorsCount = (int)sourceCustomersErrorCountVariable.GetValue(); Assert.AreEqual(0, errorsCount); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; Assert.AreEqual(1, dataTaps.Count); CheckDataTap1(dataTaps); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers]\[DFT Convert customer names].[CustomerCount]"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); Assert.AreEqual(1, context.FakeDestinations.Count); FakeDestination fakeDestination = context.FakeDestinations[0]; foreach (FakeDestinationSnapshot snapshot in fakeDestination.Snapshots) { string data = snapshot.LoadData(); string[] rows = data.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("1;COMPANY1;", rows[0]); Assert.AreEqual("5;COMPANY2;", rows[1]); Assert.AreEqual("11;COMPANY3;", rows[2]); } }
protected override void Verify(VerificationContext context) { context.Package.ThrowExceptionOnError(); Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); DtsVariable customerCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[CustomerCount]"); var customersCount = (int)customerCountVariable.GetValue(); Assert.AreEqual(4, customersCount); DtsVariable sourceCustomersErrorCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[SourceCustomersErrorCount]"); var errorsCount = (int)sourceCustomersErrorCountVariable.GetValue(); Assert.AreEqual(2, errorsCount); DtsVariable firstCustomerVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[FirstCustomer]"); var customerName = (string)firstCustomerVariable.GetValue(); Assert.AreEqual("pg", customerName); DtsVariable secondCustomerVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[SecondCustomer]"); customerName = (string)secondCustomerVariable.GetValue(); Assert.AreEqual("irg", customerName); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; Assert.AreEqual(7, dataTaps.Count); CheckDataTap1(dataTaps); CheckDataTap2(dataTaps); CheckDataTap3(dataTaps); CheckDataTap4(dataTaps); CheckDataTap5(dataTaps); CheckDataTap6(dataTaps); CheckDataTap7(dataTaps); Assert.AreEqual(1, context.FakeDestinations.Count); FakeDestination fakeDestination = context.FakeDestinations[0]; foreach (FakeDestinationSnapshot snapshot in fakeDestination.Snapshots) { string data = snapshot.LoadData(); string[] rows = data.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("911;LG;", rows[0]); Assert.AreEqual("1908;PG;", rows[1]); Assert.AreEqual("1924;PIL;", rows[2]); Assert.AreEqual("2401;IRG;", rows[3]); } }
protected override void Setup(SetupContext context) { DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); variable.SetValue(0); DtsVariable variable2 = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomersImported]"); variable2.SetValue(true); }
public void TestWholePackage(ActionContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); var countInsert = (int)variable.GetValue(); Assert.AreEqual(3, countInsert); }
public void TestEvent(ActionContext context) { Assert.AreEqual(true, context.ActiveExecutable.IsExecutionSuccess); DtsVariable variable = context.ActiveExecutable.GetVariable(@"ExecutedId"); var id = (int)variable.GetValue(); Assert.AreEqual(1908, id); }
protected override void Setup(SetupContext context) { DtsVariable custDestNew = context.Package.GetVariableForPath(@"\[CopyCustomers2].[ConvertDestinationPath]"); custDestNew.SetValue(Constants.CustomersFileConverted); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers2]\[DFT Convert customer names].[CustomerCount]"); variable.SetValue(0); }
protected override void Setup(SetupContext context) { DtsVariable custSrc = context.Package.GetVariableForPath(@"\[CopyCustomers].[SourcePath]"); custSrc.SetValue(Constants.CustomersFileSource); DtsVariable custDest = context.Package.GetVariable(@"DestinationPath"); custDest.SetValue(Constants.CustomersFileDestination); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(false, context.Package.IsExecutionSuccess); Assert.AreEqual(false, context.ActiveExecutable.IsExecutionSuccess); DtsVariable variable = context.Package.GetVariable(@"CustomersImported"); var value = (bool)variable.GetValue(); Assert.AreEqual(false, value); }
public void TestConvertCustomerNames(ActionContext context) { Assert.AreEqual(true, context.ActiveExecutable.IsExecutionSuccess); DtsVariable variable = context.ActiveExecutable.GetVariable(@"CustomerCount"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); CheckDataTaps(context); }
public void TestLoop(ActionContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); DtsVariable index = context.Package.GetVariableForPath(@"\[Loop]\[FOR].[index]"); DtsVariable maxIterations = context.Package.GetVariableForPath(@"\[Loop]\[FOR].[maxIterations]"); var indexVal = (int)index.GetValue(); var maxIterationsVal = (int)maxIterations.GetValue(); Assert.IsTrue(indexVal <= maxIterationsVal); }
protected override void Setup(SetupContext context) { ReplaceConnectionStrings(); var config = context.Package.GetConfiguration("ConnectionStrings"); config.SetConfigurationString(Constants.PathToDtsConfig); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomersWithConfig]\[DFT Convert customer names].[CustomerCount]"); variable.SetValue(0); }
protected override void Setup(SetupContext context) { File.Copy(Constants.CustomersFileSource, Constants.CustomersFileDestination); DtsVariable custDest = context.Package.GetVariableForPath(@"\[CopyCustomers].[DestinationPath]"); custDest.SetValue(Constants.CustomersFileDestination); DtsVariable custDestNew = context.Package.GetVariable(@"ConvertDestinationPath"); custDestNew.SetValue(Constants.CustomersFileConverted); }
protected override void Verify(VerificationContext context) { context.Package.ThrowExceptionOnError(); Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); DtsVariable customerCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers4]\[DFT Convert customer names].[CustomerCount]"); var customersCount = (int)customerCountVariable.GetValue(); Assert.AreEqual(13, customersCount); DtsVariable sourceCustomersErrorCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers4]\[DFT Convert customer names].[SourceCustomersErrorCount]"); var errorsCount = (int)sourceCustomersErrorCountVariable.GetValue(); Assert.AreEqual(0, errorsCount); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; Assert.AreEqual(1, dataTaps.Count); CheckDataTap1(dataTaps); Assert.AreEqual(1, context.FakeDestinations.Count); FakeDestination fakeDestination = context.FakeDestinations[0]; foreach (FakeDestinationSnapshot snapshot in fakeDestination.Snapshots) { string data = snapshot.LoadData(); string[] rows = data.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); int i = 0; Assert.AreEqual("1;Company1;table;1;".ToUpper(), rows[i]); Assert.AreEqual("1;Company1;chair;4;".ToUpper(), rows[++i]); Assert.AreEqual("1;Company1;glass;5;".ToUpper(), rows[++i]); Assert.AreEqual("2;furniture co;;;".ToUpper(), rows[++i]); Assert.AreEqual("5;Company2;car;2;".ToUpper(), rows[++i]); Assert.AreEqual("5;Company2;motor;6;".ToUpper(), rows[++i]); Assert.AreEqual("5;Company2;radio;9;".ToUpper(), rows[++i]); Assert.AreEqual("5;Company2;navi;10;".ToUpper(), rows[++i]); Assert.AreEqual("7;used cars;;;".ToUpper(), rows[++i]); Assert.AreEqual("11;Company3;laptop;3;".ToUpper(), rows[++i]); Assert.AreEqual("11;Company3;monitor;7;".ToUpper(), rows[++i]); Assert.AreEqual("11;Company3;mouse;8;".ToUpper(), rows[++i]); Assert.AreEqual("18;computers;;;".ToUpper(), rows[++i]); } }
protected override void Setup(SetupContext context) { DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); variable.SetValue(0); _dummyConstraint = context.Package.GetPrecedingConstraintForPath(@"\[LoadCustomers]\[SCR Dummy].[DummyConstraint]"); _dummyConstraint.SetExecutionResult(DtsExecutionResult.Success); _countConstraint = context.Package.GetPrecedingConstraintForPath(@"\[LoadCustomers]\[SEQC Load]\[SQL Get Count of data in destination].[CountConstraint]"); _countConstraint.SetExecutionResult(DtsExecutionResult.Success); }
public void TestConvertCustomerNames(ActionContext context) { bool exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, context.ActiveExecutable.IsExecutionSuccess); Assert.AreEqual(true, exists); DtsVariable variable = context.ActiveExecutable.GetVariable(@"CustomerCount"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); }
protected override void Setup(SetupContext context) { File.Copy(Constants.CustomersFileSource, Constants.CustomersFileDestination); context.Package.GetConnection("CustomerDB").SetConnectionString(Constants.SsisDbConnectionString); context.Package.GetConnection("Customers Src").SetConnectionString(Constants.CustomersFileSource); DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); variable.SetValue(0); DtsVariable variable2 = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomersImported]"); variable2.SetValue(false); }
protected override void Verify(VerificationContext context) { Assert.IsTrue(context.ActiveExecutable.IsExecutionSuccess); DtsVariable indexVar = context.Package.GetVariable("index"); var indexVarVal = (int)indexVar.GetValue(); Assert.IsTrue(indexVarVal == 5); DtsVariable customerCntVar = context.Package.GetVariableForPath(@"\[LoopWithDataFlow]\[FOR]\[DFT Convert customer names].[CustomerCount]"); var customerCntVarVal = (int)customerCntVar.GetValue(); Assert.IsTrue(customerCntVarVal == 3); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers]\[DFT Convert customer names].[CustomerCount]"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; DataTap dataTap = dataTaps[0]; foreach (DataTapSnapshot snapshot in dataTap.Snapshots) { string data = snapshot.LoadData(); Assert.IsFalse(string.IsNullOrEmpty(data)); string[] rows = data.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("1908;PG;", rows[0]); Assert.AreEqual("2401;IRG;", rows[1]); Assert.AreEqual("911;LG;", rows[2]); } DtsVariable sourceCustomersErrorCount = context.Package.GetVariableForPath(@"\[CopyCustomers]\[DFT Convert customer names].[SourceCustomersErrorCount]"); var val = (int)sourceCustomersErrorCount.GetValue(); Assert.AreEqual(2, val); Assert.AreEqual(1, context.FakeDestinations.Count); FakeDestination fakeDestination = context.FakeDestinations[0]; foreach (FakeDestinationSnapshot snapshot in fakeDestination.Snapshots) { string data = snapshot.LoadData(); string[] rows = data.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries); Assert.AreEqual("1908;PG;", rows[0]); Assert.AreEqual("2401;IRG;", rows[1]); Assert.AreEqual("911;LG;", rows[2]); } }
protected override void Verify(VerificationContext context) { context.Package.ThrowExceptionOnError(); Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, exists); DtsVariable customerCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[CustomerCount]"); var customersCount = (int)customerCountVariable.GetValue(); Assert.AreEqual(4, customersCount); DtsVariable sourceCustomersErrorCountVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[SourceCustomersErrorCount]"); var errorsCount = (int)sourceCustomersErrorCountVariable.GetValue(); Assert.AreEqual(2, errorsCount); DtsVariable firstCustomerVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[FirstCustomer]"); var customerName = (string)firstCustomerVariable.GetValue(); Assert.AreEqual("pg", customerName); DtsVariable secondCustomerVariable = context.Package.GetVariableForPath(@"\[CopyCustomers3]\[DFT Convert customer names].[SecondCustomer]"); customerName = (string)secondCustomerVariable.GetValue(); Assert.AreEqual("irg", customerName); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; Assert.AreEqual(7, dataTaps.Count); CheckDataTap1(dataTaps); CheckDataTap2(dataTaps); CheckDataTap3(dataTaps); CheckDataTap4(dataTaps); CheckDataTap5(dataTaps); CheckDataTap6(dataTaps); CheckDataTap7(dataTaps); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); Assert.AreEqual(true, context.ActiveExecutable.IsExecutionSuccess); context.DataAccess.OpenConnection(Constants.DbConnectionString); var rowCount = (int)context.DataAccess.ExecuteScalar(@"select count(*) from [dbo].[CustomersStaging]"); context.DataAccess.CloseConnection(); DtsVariable variable = context.Package.GetVariable(@"CustomerCount"); var countInsert = (int)variable.GetValue(); Assert.AreEqual(2, rowCount); Assert.AreEqual(2, countInsert); }
protected override void Setup(SetupContext context) { DtsParameter custSrcParam = context.Package.Project.GetParameter(@"SourcePath"); custSrcParam.SetValue(Constants.CustomersFileSource); DtsParameter custDesParam = context.Package.Project.GetParameter(@"DestinationPath"); custDesParam.SetValue(Constants.CustomersFileDestination); DtsParameter custDesConvertedParam = context.Package.Project.GetParameter(@"ConvertDestinationPath"); custDesConvertedParam.SetValue(Constants.CustomersFileConverted); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers]\[DFT Convert customer names].[CustomerCount]"); variable.SetValue(0); }
protected override void Setup(SetupContext context) { DtsVariable custSrc = context.Package.GetVariableForPath(@"\[LoopWithDataFlow].[SourcePath]"); custSrc.SetValue(Constants.CustomersFileSource); DtsVariable custDest = context.Package.GetVariableForPath(@"\[LoopWithDataFlow].[DestinationPath]"); custDest.SetValue(Constants.CustomersFileDestination); DtsVariable custDestNew = context.Package.GetVariable(@"ConvertDestinationPath"); custDestNew.SetValue(Constants.CustomersFileConverted); DtsVariable variable = context.Package.GetVariableForPath(@"\[LoopWithDataFlow]\[FOR]\[DFT Convert customer names].[CustomerCount]"); variable.SetValue(0); }
protected override void Setup(SetupContext context) { context.Package.GetConnection("CustomerDB").SetConnectionString(Constants.SsisDbConnectionString); context.Package.GetConnection("Customers Src").SetConnectionString(Constants.CustomersFileSource); DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); variable.SetValue(0); const string query = @"insert into [dbo].[CustomersStaging] ([Id], [Name]) values (1, 'ACME') ,(2, 'ALL')"; context.DataAccess.OpenConnection(Constants.DbConnectionString); context.DataAccess.ExecuteNonQuery(query); context.DataAccess.CloseConnection(); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, exists); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomersWithConfig]\[DFT Convert customer names].[CustomerCount]"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); context.DataAccess.OpenConnection(Constants.DbConnectionString); var rowCount = (int)context.DataAccess.ExecuteScalar(@"select count(*) from [dbo].[CustomersStaging]"); context.DataAccess.CloseConnection(); DtsVariable variable = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomerCount]"); var countInsert = (int)variable.GetValue(); DtsVariable variable2 = context.Package.GetVariableForPath(@"\[LoadCustomers].[CustomersImported]"); var value = (bool)variable2.GetValue(); Assert.AreEqual(3, rowCount); Assert.AreEqual(3, countInsert); Assert.AreEqual(true, value); }
protected override void Verify(VerificationContext context) { context.Package.ThrowExceptionOnError(); Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, exists); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers2]\[DFT Convert customer names].[CustomerCount]"); int count = (int)variable.GetValue(); Assert.AreEqual(6, count); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; CheckDataTap1(dataTaps); CheckDataTap2(dataTaps); }
protected override void Verify(VerificationContext context) { Assert.AreEqual(true, context.Package.IsExecutionSuccess); bool exists = File.Exists(Constants.CustomersFileDestination); Assert.AreEqual(true, exists); exists = File.Exists(Constants.CustomersFileConverted); Assert.AreEqual(true, exists); DtsVariable variable = context.Package.GetVariableForPath(@"\[CopyCustomers]\[DFT Convert customer names].[CustomerCount]"); var count = (int)variable.GetValue(); Assert.AreEqual(3, count); ReadOnlyCollection <DataTap> dataTaps = context.DataTaps; DataTap dataTap = dataTaps[0]; foreach (DataTapSnapshot snapshot in dataTap.Snapshots) { string data = snapshot.LoadData(); Assert.IsFalse(string.IsNullOrEmpty(data)); } DataTap dataTap1 = dataTaps[1]; foreach (DataTapSnapshot snapshot in dataTap1.Snapshots) { string data = snapshot.LoadData(); Assert.IsFalse(string.IsNullOrEmpty(data)); } }