public void WriterWithHeaderTest() { string path = "csv-samples/WriterWithHeaderTest.csv"; string header = "DateTime,Open,High,Low,Close,Volume"; try { Assert.AreEqual(false, File.Exists(path)); using (var writer = new CsvWriter<StockValue>(path, containsHeader: true, separator: ',')) { Assert.AreEqual(true, File.Exists(path)); for (int i = 0; i < 30; i++) { writer.WriteObj(new StockValue { DateTime = DateTime.Now, Open = i * 10, High = i * 90, Low = i * 5, Close = i * 35, Volume = 1029387465 / (i + 1) }); } } Assert.AreEqual(header, File.ReadLines(path).First()); Assert.AreEqual(30 + 1, File.ReadLines(path).Count()); } catch (Exception e) { throw e; } finally { File.Delete(path); Assert.AreNotEqual(true, File.Exists(path)); } }