public void CreateErrorTable(IConnectionManager connection) { //Arrange //Act CreateErrorTableTask.Create(connection, "etlbox_error"); //Assert IfTableOrViewExistsTask.IsExisting(connection, "etlbox_error"); var td = TableDefinition.FromName(connection, "etlbox_error"); Assert.True(td.Columns.Count == 3); //Cleanup DropTableTask.Drop(connection, "etlbox_error"); }
public void ReCreateErrorTable(IConnectionManager connection) { //Arrange //Act CreateTableTask.Create(connection, "etlbox_error", new List <TableColumn>() { new TableColumn("Col1", "INT") }); CreateErrorTableTask.DropAndCreate(connection, "etlbox_error"); //Assert var td = TableDefinition.FromName(connection, "etlbox_error"); Assert.True(td.Columns.Count == 3); //Cleanup DropTableTask.Drop(connection, "etlbox_error"); }
public void ThrowExceptionInFlow() { //Arrange TwoColumnsTableFixture dest2Columns = new TwoColumnsTableFixture("RowTransExceptionTest"); CsvSource <string[]> source = new CsvSource <string[]>("res/RowTransformation/TwoColumns.csv"); DbDestination <MySimpleRow> dest = new DbDestination <MySimpleRow>(SqlConnection, "RowTransExceptionTest"); CreateErrorTableTask.DropAndCreate(SqlConnection, "errors"); DbDestination <ETLBoxError> errorDest = new DbDestination <ETLBoxError>(SqlConnection, "errors"); //Act RowTransformation <string[], MySimpleRow> trans = new RowTransformation <string[], MySimpleRow>( csvdata => { int no = int.Parse(csvdata[0]); if (no == 2) { throw new Exception("Test"); } return(new MySimpleRow() { Col1 = no, Col2 = csvdata[1] }); }); source.LinkTo(trans); trans.LinkTo(dest); trans.LinkErrorTo(errorDest); source.Execute(); dest.Wait(); errorDest.Wait(); //Assert Assert.Equal(2, RowCountTask.Count(SqlConnection, "RowTransExceptionTest")); Assert.Equal(1, RowCountTask.Count(SqlConnection, "errors")); }
public void WriteIntoMultipleDestinations() { //Arrange var source = new MemorySource <string[]>(); source.DataAsList.Add(new string[] { "Test" }); var trans = new RowTransformation <string[]>(); trans.TransformationFunc = r => throw new Exception(); var dest = new MemoryDestination <string[]>(); CreateErrorTableTask.Create(SqlConnection, "error_log"); var mc = new Multicast <ETLBoxError>(); var errorMem = new MemoryDestination <ETLBoxError>(); var errorDb = new DbDestination <ETLBoxError>(SqlConnection, "error_log"); var errorCsv = new CsvDestination <ETLBoxError>("error_csv.csv"); source.LinkTo(trans); trans.LinkTo(dest); //Act trans.LinkErrorTo(mc); mc.LinkTo(errorMem); mc.LinkTo(errorDb); mc.LinkTo(errorCsv); source.Execute(); dest.Wait(); errorMem.Wait(); errorDb.Wait(); errorCsv.Wait(); //Assert Assert.True(errorMem.Data.Count > 0); Assert.True(RowCountTask.Count(SqlConnection, "error_log") > 0); Assert.True(File.ReadAllText("error_csv.csv").Length > 0); }