public void CSVAttributeNoHeaderTest() { var stream = new System.IO.MemoryStream(); var text = "A,B\r\nD,E"; var bytes = System.Text.Encoding.UTF8.GetBytes(text); stream.Write(bytes, 0, bytes.Length); stream.Position = 0; var target = new CSVSource<TestClass>(stream, System.Text.Encoding.UTF8); var firstLine = target.ReadNext(); Assert.AreEqual("A", firstLine.Col1); Assert.AreEqual("B", firstLine.Col2); //Without Index stream = new System.IO.MemoryStream(); text = "A,B\r\nD,E"; bytes = System.Text.Encoding.UTF8.GetBytes(text); stream.Write(bytes, 0, bytes.Length); stream.Position = 0; var target2 = new CSVSource<TestClass2>(stream, System.Text.Encoding.UTF8); var firstLine2 = target2.ReadNext(); Assert.IsNull(firstLine2.Col1); Assert.IsNull(firstLine2.Col2); }
public void CSVAttributeWithSkipRowCountOnReadingEmptyTextTest() { var stream = new System.IO.MemoryStream(); var text = ""; var bytes = System.Text.Encoding.UTF8.GetBytes(text); stream.Write(bytes, 0, bytes.Length); stream.Position = 0; var target = new CSVSource<TestClass3>(stream, System.Text.Encoding.UTF8); var firstLine = target.ReadNext(); Assert.IsNull(firstLine); }
public void CSVAttributeWithSkipRowCountTest() { var stream = new System.IO.MemoryStream(); var text = "\r\n\r\nCol1,Col2\r\nA,B\r\nD,E"; var bytes = System.Text.Encoding.UTF8.GetBytes(text); stream.Write(bytes, 0, bytes.Length); stream.Position = 0; var target = new CSVSource<TestClass3>(stream, System.Text.Encoding.UTF8); var firstLine = target.ReadNext(); Assert.AreEqual("A", firstLine.Col1); Assert.AreEqual("B", firstLine.Col2); }