public void SerializesDateTime() { _uut.StartRow(); _uut["A"] = new System.DateTime(2015, 4, 27, 13, 14, 15); CsvAssert.IsEqual(_uut, new[] { "A", "2015-04-27 13:14:15" }); }
public void EscapesQuotes() { _uut.StartRow(); _uut["A"] = "foo\"bar"; CsvAssert.IsEqual(_uut, new[] { "A", @"""foo""""bar""" }); }
public void EscapesDelimiter() { _uut.StartRow(); _uut["A"] = "1,5"; CsvAssert.IsEqual(_uut, new[] { "A", @"""1,5""" }); }
public void DictionaryToCsv() { var someDictionary = new Dictionary <string, int> { { "foo", 1 }, { "bar", 2 } }; var actual = someDictionary.ToCsv(); CsvAssert.IsEqual(actual, new[] { "key,value", "foo,1", "bar,2" }); }
public void SortsByFieldName() { _uut.StartRow(); _uut["B"] = 2; _uut["A"] = 1; _uut["Z"] = 4; _uut["C"] = 3; CsvAssert.IsEqual(_uut, new[] { "A,B,C,Z", "1,2,3,4" }, CsvBuilder.SortFields.ByName); }
public void HandlesMissingValues() { _uut.StartRow(); _uut["A"] = 1; _uut["B"] = 2; _uut.StartRow(); _uut["A"] = 3; CsvAssert.IsEqual(_uut, new[] { "A,B", "1,2", "3," }); }
public void SortsByFieldNameExcludeFirstField() { _uut.StartRow(); _uut["Header"] = 0; _uut["A"] = 1; _uut["Z"] = 3; _uut["C"] = 2; CsvAssert.IsEqual(_uut, new[] { "Header,A,C,Z", "0,1,2,3" }, CsvBuilder.SortFields.ByNameLeaveFirst); }
public void AddsColumnsAndFields() { _uut.StartRow(); _uut["A"] = 1; _uut["B"] = 2; _uut.StartRow(); _uut["A"] = 3; _uut["B"] = 4; CsvAssert.IsEqual(_uut, new[] { "A,B", "1,2", "3,4" }); }