Пример #1
0
        public void TestFile()
        {
            using (var writer = new CsvStreamWriter <TypeModel>("type.writer.csv"))
            {
                writer.WriteHeader();
                for (var i = 0; i < 25; ++i)
                {
                    writer.WriteLine(new TypeModel()
                    {
                        Int32 = i, Char = 'A'
                    });
                }
            }

            // Parse the respones and check if it was saved correctly.
            var entries = CsvParser.ParseFile <TypeModel>("type.writer.csv", new CsvStreamOptions()
            {
                RemoveEmptyEntries = true
            }).ToList();

            Assert.AreEqual(entries.Count(), 25);

            var index = 0;

            foreach (var entry in entries)
            {
                Assert.AreEqual(entry.Char, 'A');
                Assert.AreEqual(entry.Int32, index++);
            }
        }