public CsvColumn(string title, Func <T, object> func, bool formatAsText, IExcelSanitizer excelSanitizer) { Title = title; this.func = func; this.formatAsText = formatAsText; this.excelSanitizer = excelSanitizer; }
public void CsvWriter_WithExcelSanitizer_SanitizesValues() { // Arrange IExcelSanitizer sanitizer = A.Fake <IExcelSanitizer>(); A.CallTo(() => sanitizer.IsThreat("Bad String")).Returns(true); A.CallTo(() => sanitizer.Sanitize("Bad String")).Returns("Sanitized Bad String"); CsvWriter <string> writer = new CsvWriter <string>(sanitizer); writer.DefineColumn("Column 1", x => x); List <string> data = new List <string>() { "Good String", "Bad String" }; // Act string csv = writer.Write(data); // Assert string expectedValue = "Column 1" + Environment.NewLine + "Good String" + Environment.NewLine + "Sanitized Bad String" + Environment.NewLine; Assert.Equal(expectedValue, csv); }
public CsvWriterFactory(IExcelSanitizer excelSanitizer) { this.excelSanitizer = excelSanitizer; }