public void CanMakeSimpleCsvRowFromStringEnumerable() { var list = new[] { "a", "b", "c" }; const string expectedOutput = "\"a\",\"b\",\"c\""; var actualOutput = ToCsvExtensionMethods.EnumerableStringToCsvRow(list); Assert.That(actualOutput, Is.EqualTo(expectedOutput), "Should be able to turn a string list into a CSV row."); }
public void CanEscape() { Assert.That(ToCsvExtensionMethods.CsvEscape(null), Is.EqualTo(String.Empty), "null should be empty"); Assert.That(ToCsvExtensionMethods.CsvEscape(String.Empty), Is.EqualTo(String.Empty), "Empty should be empty"); Assert.That(ToCsvExtensionMethods.CsvEscape("Simple"), Is.EqualTo("\"Simple\"")); Assert.That(ToCsvExtensionMethods.CsvEscape("With,Comma"), Is.EqualTo("\"With,Comma\"")); Assert.That(ToCsvExtensionMethods.CsvEscape("With\"DoubleQuote"), Is.EqualTo("\"With\"\"DoubleQuote\"")); Assert.That(ToCsvExtensionMethods.CsvEscape("With\r\nNewLine"), Is.EqualTo("\"With\r\nNewLine\"")); Assert.That(ToCsvExtensionMethods.CsvEscape("With\nNewLine"), Is.EqualTo("\"With\nNewLine\"")); }