public void Does_use_CsvConfig() { CsvConfig.ItemSeperatorString = "|"; CsvConfig.ItemDelimiterString = "`"; CsvConfig.RowSeparatorString = "\n\n"; var dtos = new[] { new ModelWithIdAndName { Id = 1, Name = "Value" }, new ModelWithIdAndName { Id = 2, Name = "Value|Escaped" }, }; var csv = dtos.ToCsv(); Assert.That(csv, Is.EqualTo("Id|Name\n\n1|Value\n\n2|`Value|Escaped`\n\n")); var maps = new List<Dictionary<string, object>>() { new Dictionary<string,object> { {"Id", "1"}, {"Name", "Value"} }, new Dictionary<string,object> { {"Id", "2"}, {"Name", "Value|Escaped"} }, }; csv = maps.ToCsv(); Assert.That(csv, Is.EqualTo("Id|Name\n\n1|Value\n\n2|`Value|Escaped`\n\n")); CsvConfig.ItemSeperatorString = JsWriter.ItemSeperatorString; CsvConfig.ItemDelimiterString = JsWriter.QuoteString; CsvConfig.RowSeparatorString = Environment.NewLine; }
public void CanCreateCsvStringFromStringEnumerable() { var strings = new [] { "a", "b", "c" }; var csv = strings.ToCsv(); Assert.Equal("a,b,c", csv); }
public void ToCsv_ShouldReturnDelimitedValues() { const string delimiter = "..."; var test = new[] {"LOL", "ROFL", "1337"}; var csv = test.ToCsv(delimiter); Assert.That(csv, Is.EqualTo("LOL...ROFL...1337")); }
public void StringEnumerableWithOneStringHasNoCommas() { var strings = new[] { "a" }; var csv = strings.ToCsv(); Assert.DoesNotContain(",", csv); Assert.Equal("a", csv); }
public void ToCsvTest2() { var data = new[,] {{"a", "b", "c"}, {"d", "e", "f"}, {"g", "h", "i"}}; var expected = "a,b,c" + Environment.NewLine + "d,e,f" + Environment.NewLine + "g,h,i"; Assert.AreEqual(expected, data.ToCsv()); }
public void StringToCsvTest() { string[] messages = new[] { "a", "b", "c" }; Assert.AreEqual(messages.ToCsv(), "a,b,c"); Assert.AreEqual(messages.ToCsv("-", "! ", " ."), "! a .-! b .-! c ."); }