public void WithPredicate() { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture("RowDuplicationSource"); source2Columns.InsertTestData(); DbSource source = new DbSource(SqlConnection, "RowDuplicationSource"); RowDuplication duplication = new RowDuplication( row => { dynamic r = row as dynamic; return(r.Col1 == 1 || r.Col2 == "Test3"); }); MemoryDestination dest = new MemoryDestination(); //Act source.LinkTo(duplication); duplication.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Collection(dest.Data, row => { dynamic d = row as dynamic; Assert.True(d.Col1 == 1 && d.Col2 == "Test1"); }, row => { dynamic d = row as dynamic; Assert.True(d.Col1 == 1 && d.Col2 == "Test1"); }, row => { dynamic d = row as dynamic; Assert.True(d.Col1 == 2 && d.Col2 == "Test2"); }, row => { dynamic d = row as dynamic; Assert.True(d.Col1 == 3 && d.Col2 == "Test3"); }, row => { dynamic d = row as dynamic; Assert.True(d.Col1 == 3 && d.Col2 == "Test3"); } ); }
public void DataIsInList() { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture("RowDuplicationStringArraySource"); source2Columns.InsertTestData(); DbSource <string[]> source = new DbSource <string[]>(SqlConnection, "RowDuplicationStringArraySource"); RowDuplication <string[]> duplication = new RowDuplication <string[]>(); MemoryDestination <string[]> dest = new MemoryDestination <string[]>(); //Act source.LinkTo(duplication); duplication.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Collection(dest.Data, d => Assert.True(d[0] == "1" && d[1] == "Test1"), d => Assert.True(d[0] == "1" && d[1] == "Test1"), d => Assert.True(d[0] == "2" && d[1] == "Test2"), d => Assert.True(d[0] == "2" && d[1] == "Test2"), d => Assert.True(d[0] == "3" && d[1] == "Test3"), d => Assert.True(d[0] == "3" && d[1] == "Test3") ); }
public void WithPredicate() { //Arrange TwoColumnsTableFixture source2Columns = new TwoColumnsTableFixture("RowDuplicationSource"); source2Columns.InsertTestData(); DbSource <MySimpleRow> source = new DbSource <MySimpleRow>(SqlConnection, "RowDuplicationSource"); RowDuplication <MySimpleRow> duplication = new RowDuplication <MySimpleRow>( row => row.Col1 == 1 || row.Col2 == "Test3" ); MemoryDestination <MySimpleRow> dest = new MemoryDestination <MySimpleRow>(); //Act source.LinkTo(duplication); duplication.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Collection(dest.Data, d => Assert.True(d.Col1 == 1 && d.Col2 == "Test1"), d => Assert.True(d.Col1 == 1 && d.Col2 == "Test1"), d => Assert.True(d.Col1 == 2 && d.Col2 == "Test2"), d => Assert.True(d.Col1 == 3 && d.Col2 == "Test3"), d => Assert.True(d.Col1 == 3 && d.Col2 == "Test3") ); }
public void IgnoreWithObject() { //Arrange MemorySource <MySimpleRow> source = new MemorySource <MySimpleRow>(); source.DataAsList = new List <MySimpleRow>() { null, new MySimpleRow() { Col1 = 1, Col2 = "Test1" }, null, new MySimpleRow() { Col1 = 2, Col2 = "Test2" }, new MySimpleRow() { Col1 = 3, Col2 = "Test3" }, null }; //Act RowDuplication <MySimpleRow> duplication = new RowDuplication <MySimpleRow>(); MemoryDestination <MySimpleRow> dest = new MemoryDestination <MySimpleRow>(); source.LinkTo(duplication); duplication.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Collection(dest.Data, d => Assert.True(d.Col1 == 1 && d.Col2 == "Test1"), d => Assert.True(d.Col1 == 1 && d.Col2 == "Test1"), d => Assert.True(d.Col1 == 2 && d.Col2 == "Test2"), d => Assert.True(d.Col1 == 2 && d.Col2 == "Test2"), d => Assert.True(d.Col1 == 3 && d.Col2 == "Test3"), d => Assert.True(d.Col1 == 3 && d.Col2 == "Test3") ); }
public void NoParameter() { //Arrange MemorySource <MyEnumRow> source = new MemorySource <MyEnumRow>(); source.DataAsList.Add(new MyEnumRow() { EnumCol = EnumType.Value2 }); RowDuplication <MyEnumRow> duplication = new RowDuplication <MyEnumRow>(); MemoryDestination <MyEnumRow> dest = new MemoryDestination <MyEnumRow>(); //Act source.LinkTo(duplication); duplication.LinkTo(dest); source.Execute(); dest.Wait(); //Assert Assert.Collection <MyEnumRow>(dest.Data, d => Assert.True(d.EnumCol == EnumType.Value2), d => Assert.True(d.EnumCol == EnumType.Value2) ); }