Exemplo n.º 1
0
        public void BuildFromListEmpty()
        {
            var persons   = Array.Empty <Person>();
            var expect    = @"""Person Name"",""Id""".Trim();
            var generator = new CSVGenerator();
            var generated = generator.BuildFromCollection(persons).BytesToString();

            Assert.AreEqual(expect, generated.Trim());
        }
Exemplo n.º 2
0
        public void BuildFromList()
        {
            var persons = new[] {
                new Person {
                    Id = 1, Name = "Alice Li"
                },
                new Person {
                    Id = 2, Name = "我能吞下玻璃而不伤身体。"
                },
            };
            var expect    = "\"Person Name\",\"Id\"\r\n\"Alice Li\",\"1\"\r\n\"我能吞下玻璃而不伤身体。\",\"2\"".Trim();
            var generator = new CSVGenerator();
            var generated = generator.BuildFromCollection(persons).BytesToString();

            Assert.AreEqual(expect, generated.Trim());
        }