public void TestSimpleCSVRender(string fileContents, int numberRows) { string newFolder = Guid.NewGuid().ToString("N"); var dir = Path.Combine(Environment.CurrentDirectory, newFolder); Directory.CreateDirectory(dir); IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {numberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRows)); $"and now use SenderRazorTableOneByOne ".w(async() => { data = await new SenderRazorTableOneByOne("aaa", dir).TransformData(data); }); $"and the new folder {dir} should have 1 file".w(() => { Directory.GetFiles(dir).Length.Should().Be(1); }); }
public void TestSimpleCSVWithConst(string fileContents, int NumberRows, string newVal) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows)); $"and now I send to razor {nameof(SenderToRazorWithContents)}".w(async() => { data = await new SenderToRazorWithContents("asdasdasd").TransformData(data); }); $"and I can transform the value of the output ".w(async() => { data = await new TransformerOutputStringColumnName(newVal).TransformData(data); }); $"should be the value equal to {newVal}".w(() => { data.FindAfterName("OutputString").Value.Rows[0]["Name"].ToString().Should().Be(newVal.Replace("'", "")); }); }
public void TestSimpleCSV(string fileContents, int NumberRows, int NumberRowsAfterFilter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows)); $"And when I filter".w(async() => data = await new FilterRemoveColumnDataGreaterThanLength("Car", 5).TransformData(data)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRowsAfterFilter}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRowsAfterFilter)); }
public void TestSimpleCSV(string fileContents, int NumberRows) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows)); var filesCSV = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.json"); foreach (var f in filesCSV) { File.Delete(f); } $" and no csv files existing".w(() => Directory.GetFiles(Directory.GetCurrentDirectory(), "*.csv").Length.Should().Be(0)); $"and now I export to json to the current folder".w(async() => data = await new SenderDefinitionToFile("a.json").TransformData(data)); $" and now 1 json files existing".w(() => Directory.GetFiles(Directory.GetCurrentDirectory(), "*.json").Length.Should().Be(1)); }
public void TestSimpleCSV(string fileContents, int numberRows, string filter, string contain, int numberRowsAfterFilter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With 1 tables and {numberRows} rows".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRows); }); $"And when I filter with {filter} {contain} ".w(async() => data = await new FilterRetainColumnDataContains(filter, contain).TransformData(data)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With 1 table and {numberRowsAfterFilter} after filter".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); data.DataToBeSentFurther[0].Rows.Count.Should().Be(numberRowsAfterFilter); }); }
public void TestSimpleSenderOutputToExcel(string fileContents, int NumberRows, string fileName) { IReceive receiver = null; IDataToSent data = null; ISenderToOutput sender = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); fileName = Guid.NewGuid().ToString("N") + fileName; $"the Excel {fileName} should not exists".w(() => File.Exists(fileName).Should().BeFalse()); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows)); $"and now I want to export to excel file ".w(async() => { sender = new SenderOutputExcel(fileName); data = await sender.TransformData(data); } ); $"the Excel should exists".w(() => { sender.OutputByte.Should().NotBeNull(); sender.OutputByte.Rows.Count.Should().Be(1); }); }
public void TestSimpleCSV(string fileContents, string fromName, string toName) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"and the table should contain column name {fromName}".w(() => { data.DataToBeSentFurther[0].Columns.Contains(fromName).Should().BeTrue(); data.DataToBeSentFurther[0].Columns.Contains(toName).Should().BeFalse(); }); $"and applying {nameof(ChangeColumnName)} from {fromName} to {toName}".w(async() => data = await new ChangeColumnName(fromName, toName).TransformData(data)); $"and the table should contain column name {toName}".w(() => { data.DataToBeSentFurther[0].Columns.Contains(toName).Should().BeTrue(); data.DataToBeSentFurther[0].Columns.Contains(fromName).Should().BeFalse(); }); }
public void TestSimpleCSV(string fileContents, int nrStart, string format, string formatAfterRegex) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"and applying {nameof(TransformerRenameTablesInOrder)} with {nrStart} and {format}".w(async() => data = await new TransformerRenameTablesInOrder(nrStart, format).TransformData(data)); $"the name of the table should be {nrStart.ToString(format)}".w(() => data.DataToBeSentFurther[0].TableName.Should().Be(nrStart.ToString(format))); $" and after applying {nameof(ChangeTableNamesRegex)} ".w(async() => data = await new ChangeTableNamesRegex("(?:.+ )((?<name>.+))").TransformData(data)); $"the name of the table should be {nrStart}".w(() => data.DataToBeSentFurther[0].TableName.Should().Be(nrStart.ToString(formatAfterRegex))); }
public void TestSimpleCSV(string fileContents, int NumberRows, int splitRows, int nrTablesAfter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of rows should be {NumberRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(NumberRows)); $"and now I transform with {nameof(TransformerOneColumnToMultiTablesByNumber)}".w(async() => data = await new TransformerOneColumnToMultiTablesByNumber(data.Metadata.Tables[0].Name, splitRows).TransformData(data)); $"and now should be {nrTablesAfter} tables".w(() => data.DataToBeSentFurther.Count.Should().Be(nrTablesAfter)); }
public void TestSimpleCSV(string fileContents, string nameWithSpaces) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The first row should have spaces {nameWithSpaces}".w(() => data.DataToBeSentFurther[0].Rows[0]["Car"].Should().Be(nameWithSpaces)); $"and applying {nameof(TransformTrim)}".w(async() => data = await new TransformTrim().TransformData(data)); $"The first row should have no spaces {nameWithSpaces.Trim()}".w(() => data.DataToBeSentFurther[0].Rows[0]["Car"].Should().Be(nameWithSpaces.Trim())); }
public void TestSimpleCSV(string fileContents, int numberColsBefore, int numberColsAfter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"that have {numberColsBefore} columns".w(() => data.DataToBeSentFurther.First().Value.Columns.Count.Should().Be(numberColsBefore)); $"and applying {nameof(TransformSplitColumn)}".w(async() => data = await new TransformSplitColumn(data.Metadata.Tables[0].Name, "TwoCols", ' ').TransformData(data)); $"and now have {numberColsAfter} columns".w(() => data.DataToBeSentFurther.First().Value.Columns.Count.Should().Be(numberColsAfter)); }
public void TestSimpleCSV(string fileContents, string columnExisting, string newValue) { IReceive receiver = null; IDataToSent data = null; var nl = "\n"; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"and I aggregate all values from {columnExisting} ".w(async() => data = await new TransformerAggregateString(columnExisting, ",").TransformData(data)); $"The first row should have the values {newValue}".w(() => { data.DataToBeSentFurther[1].Rows[0][0].Should().Be(newValue); }); }
public void TestSimpleCSV(string fileContents, int nrRows, string reg, int nrRowsAfter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"with {nrRows}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(nrRows)); $" and after applying {nameof( FilterColumnDataWithRegex)} ".w(async() => data = await new FilterColumnDataWithRegex("Car", "[l]").TransformData(data)); $"the name of the table should be {nrRowsAfter}".w(() => data.DataToBeSentFurther[0].Rows.Count.Should().Be(nrRowsAfter)); }
public void TestSimpleCSV(string fileContents, string columnExisting, string newCol, string existingValue, string newValue) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"and I transform from {columnExisting} to {newCol}".w(async() => data = await new TransformerAddColumnExpressionByTable(data.Metadata.Tables[0].Name, newCol, columnExisting + "_New").TransformData(data)); $"The first row should have the values {existingValue} and {newValue}".w(() => { data.DataToBeSentFurther[0].Rows[0][columnExisting].Should().Be(existingValue); data.DataToBeSentFurther[0].Rows[0][columnExisting + "_New"].Should().Be(newValue); }); }
public void TestSimpleCSV(string fileContents, int numberTables, string filter, int numberTablesAfterFilter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With {numberTables} tables".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(numberTables); }); $"And when I filter with {filter}".w(async() => data = await new FilterTablesWithColumn(filter).TransformData(data)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With {numberTablesAfterFilter} table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(numberTablesAfterFilter); }); }
public void TestSimple(string fileContents, int NumberCols, int NumberColsAfter, string fRow1, string fRow2) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"The number of cols should be {NumberCols}".w(() => data.DataToBeSentFurther[0].Columns.Count.Should().Be(NumberCols)); $"and applying {nameof(TransformTrim)}".w(async() => data = await new TransformTrim().TransformData(data)); $"And I apply the data".w(async() => data = await new AddColumnRegex("Car_Year", @"(?:.+\/)((?<nameAuthor>.+))").TransformData(data)); $"The number of cols should be {NumberColsAfter}".w(() => data.DataToBeSentFurther[0].Columns.Count.Should().Be(NumberColsAfter)); $"The first row should have {fRow1} and {fRow2}".w(() => { data.DataToBeSentFurther[0].Rows[0][0].Should().Be(fRow1); data.DataToBeSentFurther[0].Rows[0][1].Should().Be(fRow2); }); }
public void TestSimpleCSV(string fileContents) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents = fileContents.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents}".w(() => receiver = new ReceiverCSVText(fileContents)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With a table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(1); }); $"And when I filter".w(async() => data = await new FilterRemoveTable(data.Metadata.Tables[0].Name).TransformData(data)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With 0 table".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(0); }); }
public void TestSimpleCSV(string fileContents1, string fileContents2, int nrTablesBefore, int nrTablesAfter, int nrRowsAfter) { IReceive receiver = null; IDataToSent data = null; var nl = Environment.NewLine; fileContents1 = fileContents1.Replace("{NewLine}", nl); fileContents2 = fileContents2.Replace("{NewLine}", nl); $"When I create the receiver csv for the content {fileContents1}".w(() => receiver = new ReceiverCSVText(fileContents1)); $"And I read the data".w(async() => data = await receiver.TransformData(null)); $"And I read the data from other receiver".w(async() => data = await new ReceiverCSVText(fileContents2).TransformData(data)); $"Then should be a data".w(() => data.Should().NotBeNull()); $"With {nrTablesBefore} tables".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(nrTablesBefore); }); $"and I transform to one table".w(async() => data = await new TransformerToOneTable().TransformData(data)); $"Should be {nrTablesAfter} tables".w(() => { data.DataToBeSentFurther.Should().NotBeNull(); data.DataToBeSentFurther.Count.Should().Be(nrTablesAfter); }); $"with {nrRowsAfter} rows".w(() => { data.DataToBeSentFurther[0].Rows.Count.Should().Be(nrRowsAfter); }); }