public void SpecifyingEncodingWithAStringBuilderThrowsException() { Assert.Throws <ArgumentException>(delegate { CsvWriter.Builder(new StringWriter(new StringBuilder("A;;A;T;;\r\nGreat"))).Encoding(Encoding.UTF8) .Build(); }); }
public void PassingStringBuilderDoesntCloseItOnDispose() { var b = new StringBuilder("A;;A;T;;\r\nGreat"); var w = CsvWriter.Builder(b).Build(); w.Dispose(); b.Append("Should not throw exception"); }
public void PassingTextWriterDoesntCloseItOnDispose() { var b = new StringWriter(new StringBuilder("A;;A;T;;\r\nGreat")); var w = CsvWriter.Builder((TextWriter)b).Build(); w.Dispose(); b.Write("Should not throw exception"); b.Flush(); b.Close(); }
public void AppendingNullWithWriteStringTest() { using (csvWriter = CsvWriter.Builder(stringWriter).ColumnSeparator(';').RowSeparator("\r\n") .FieldDelimiter('\"').ChunkSize(10).QuotingBehavior(QuotingBehavior.ALL).Build()) { Assert.IsNotNull(csvWriter); csvWriter.Write("").Write().Write("3").WriteLine().Write("1").Write((string)null).Write("3"); } Assert.AreEqual("\"\";\"\";\"3\"\r\n\"1\";\"\";\"3\"", stringWriter.ToString()); }
public void BuildingMethodsMaximalQuotingTest() { using (csvWriter = CsvWriter.Builder(stringWriter).ColumnSeparator(';').RowSeparator("\r\n") .FieldDelimiter('\"').ChunkSize(10).QuotingBehavior(QuotingBehavior.ALL).Build()) { Assert.IsNotNull(csvWriter); csvWriter.Write("Great").Write("Totally").Write("This is a\r\nbreak").WriteLine("").Write() .Write("Gr;eat").WriteLine("Totally").Write("Great").Write("���\"�").Write().Write("Totally"); } Assert.AreEqual("\"Great\";\"Totally\";\"This is a\r\nbreak" + "\";\"\"\r\n\"\";\"Gr;eat\";\"Totally\"\r\n\"" + "Great\";\"���\"\"�\";\"\";\"Totally\"", stringWriter.ToString()); }
public void AppendingNullWithWriteTest() { var csv = new List <List <string> >(); var row = new List <string> { "", "", "3" }; csv.Add(row); row = new List <string> { "1", null, "3" }; csv.Add(row); using (csvWriter = CsvWriter.Builder(stringWriter).ColumnSeparator(';').RowSeparator("\r\n") .FieldDelimiter('\"').ChunkSize(200).QuotingBehavior(QuotingBehavior.ALL).Build()) { Assert.IsNotNull(csvWriter); csvWriter.Write(csv); } Assert.AreEqual("\"\";\"\";\"3\"\r\n\"1\";\"\";\"3\"", stringWriter.ToString()); }
public void Setup() { stringWriter = new StringWriter(); csvWriter = CsvWriter.Builder(stringWriter).ColumnSeparator(';').RowSeparator(NEW_LINE).FieldDelimiter('\"') .Build(); }