Beispiel #1
0
        public void WriteContentsToFileTest()
        {
            var document = new CsvDocument <Person>(new Person[]
            {
                new Person {
                    Name = "Akari", Age = 20
                },
                new Person {
                    Name = "Kyoko", Age = 21
                },
                new Person {
                    Name = "Yui", Age = 22
                },
                new Person {
                    Name = "Chinatsu", Age = 19
                }
            });

            using (var tempFile = new TempFile())
            {
                document.WriteContentsToFile(tempFile.FullName);

                using var reader = new StreamReader(tempFile.FullName);
                Assert.AreEqual(
                    "Name,Age\r\n" +
                    "Akari,20\r\n" +
                    "Kyoko,21\r\n" +
                    "Yui,22\r\n" +
                    "Chinatsu,19\r\n", reader.ReadToEnd());
            }
        }
Beispiel #2
0
        public void WriteContentsToFileTest()
        {
            var document = new CsvDocument(new string[] { "name", "age" });

            document.Write("Light", 18);
            document.Write("Misa", 20);

            using (var tempFile = new TempFile())
            {
                document.WriteContentsToFile(tempFile.FullName);

                using var reader = new StreamReader(tempFile.FullName);
                Assert.AreEqual("name,age\r\nLight,18\r\nMisa,20\r\n", reader.ReadToEnd());
            }
        }