public void CaseInsensitiveColumnNames() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(0, reader.GetOrdinal("header1")); Assert.AreEqual(1, reader.GetOrdinal("HEADER2")); Assert.AreEqual(2, reader.GetOrdinal("HeaDER3")); }
public void GetValue() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); reader.Read(); string v1 = reader.GetValue(0).ToString(); Assert.AreEqual("Row1A", v1); Assert.AreEqual("Row1B", reader.GetValue(1).ToString()); }
public void DisposeReader() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(reader.IsClosed, false); reader.Close(); reader.Dispose(); reader.Dispose(); }
public void EmbeddedComma() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); reader.Read(); reader.Read(); Assert.AreEqual(reader.GetValue(0).ToString(), "Quotes"); string v1 = reader.GetValue(2).ToString(); string expected = "Q,A"; Assert.AreEqual(expected, v1); }
public void AddStaticValue() { Dictionary<String, String> staticColumns = new Dictionary<String, String>(); staticColumns.Add("Column1", "Value"); CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt", staticColumns); Assert.AreEqual(3, reader.GetOrdinal("Column1")); while (reader.Read()) { Assert.AreEqual("Value", reader.GetValue(reader.GetOrdinal("Column1"))); } reader.Close(); }
public void HeadersParse() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(0, reader.GetOrdinal("Header1")); Assert.AreEqual(1, reader.GetOrdinal("Header2")); Assert.AreEqual(2, reader.GetOrdinal("Header3")); }
public void GetOrdinalFailure() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); int i = reader.GetOrdinal("ZZZZ"); //Assert.Fail(); }
public void GetOrdinal() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(0, reader.GetOrdinal("Header1")); }
public void GetName() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual("Header1", reader.GetName(0)); }
public void FieldCount() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(3, reader.FieldCount); }
public void SimpleOpen() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); }
public void ReadAllRows() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); while (reader.Read()) { } reader.Close(); }
public void OpenAndClose() { CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt"); Assert.AreEqual(reader.IsClosed, false); reader.Close(); Assert.AreEqual(reader.IsClosed, true); }
public void GetOrdinalFailure() { using (CsvDataReader reader = new CsvDataReader(@"..\..\SimpleCsv.txt")) { int i = reader.GetOrdinal("ZZZZ"); } //Assert.Fail(); //reader.Dispose(); }
public void MoveFileUsing() { using (CsvDataReader reader = new CsvDataReader(@"..\..\MoveCsv.txt")) { Assert.AreEqual(reader.IsClosed, false); reader.Close(); Assert.AreEqual(reader.IsClosed, true); } File.Move(@"..\..\MoveCsv.txt", @"..\..\MoveCsvTemp.txt"); File.Move(@"..\..\MoveCsvTemp.txt", @"..\..\MoveCsv.txt"); }