public void CsvTokenizerTest_DoubleQouteOnRecord() { using CsvTokenizer tokenizer = new CsvTokenizer(new StringReader("aaa\"")); CsvToken token = tokenizer.NextToken(); Assert.AreEqual(CsvTokenType.Eof, token.TokenType); Assert.AreEqual("aaa\"", token.Value); }
public void CsvTokenizerTest_Disposed() { StringReader reader = new StringReader(""); CsvTokenizer tokenizer = new CsvTokenizer(reader); tokenizer.Dispose(); Assert.ThrowsException <ObjectDisposedException>(() => { reader.Read(); }); Assert.ThrowsException <ObjectDisposedException>(() => { tokenizer.NextToken(); }); }
public void CsvTokenizerTest_LRLFInDoubleQoutedValues() { using CsvTokenizer tokenizer = new CsvTokenizer(new StringReader("aaa\",\"b\r\n\"\"\",ccc")); List <string> records = new List <string>(); CsvToken token; while ((token = tokenizer.NextToken()).TokenType != CsvTokenType.Eof) { records.Add(token.Value); } records.Add(token.Value); Assert.AreEqual(3, records.Count); Assert.AreEqual("aaa\"", records[0]); Assert.AreEqual("b\r\n\"", records[1]); Assert.AreEqual("ccc", records[2]); }
public void CsvTokenizerTest_OneLineNormal() { using CsvTokenizer tokenizer = new CsvTokenizer(new StringReader(@"aaa,bbb,ccc")); List <string> records = new List <string>(); CsvToken token; while ((token = tokenizer.NextToken()).TokenType != CsvTokenType.Eof) { records.Add(token.Value); } records.Add(token.Value); Assert.AreEqual(3, records.Count); Assert.AreEqual("aaa", records[0]); Assert.AreEqual("bbb", records[1]); Assert.AreEqual("ccc", records[2]); }