public void ItShouldParse() { var expectedValues = new[] {"hello, world", "Garr", "345","123"}; var parser = new DelimiterSeparatedFieldParser(','); var actualValues = parser.Parse("\"hello, world\",\"Garr\",345,123"); for (int i = 0; i < expectedValues.Length; i++) { Assert.Equal(expectedValues[i], actualValues[i]); } }
public void ItShouldDumpIntoLastFieldWhenQuoteIsInTheMiddleOfTheLine() { var expectedValues = new[] { "hello-world", "123\",14" }; var parser = new DelimiterSeparatedFieldParser(','); var actualValues = parser.Parse("hello-world,123\",14"); for (int i = 0; i < expectedValues.Length; i++) { Assert.Equal(expectedValues[i], actualValues[i]); } }
public void ItShouldDumpIntoOneFieldWhenQuoteIsTheBeginningOfTheLine() { var expectedValues = new[] { "hello, world,123" }; var parser = new DelimiterSeparatedFieldParser(','); var actualValues = parser.Parse("\"hello, world,123"); for (int i = 0; i < expectedValues.Length; i++) { Assert.Equal(expectedValues[i], actualValues[i]); } }
public void ItShouldCleanEmptySpace() { var expectedValues = new[] { "hello-world", "Garr" }; var parser = new DelimiterSeparatedFieldParser(','); var actualValues = parser.Parse(" hello-world , Garr "); for (int i = 0; i < expectedValues.Length; i++) { Assert.Equal(expectedValues[i], actualValues[i]); } }