Esempio n. 1
0
        public void SerializesDateTime()
        {
            _uut.StartRow();
            _uut["A"] = new System.DateTime(2015, 4, 27, 13, 14, 15);

            CsvAssert.IsEqual(_uut, new[] { "A", "2015-04-27 13:14:15" });
        }
Esempio n. 2
0
        public void EscapesQuotes()
        {
            _uut.StartRow();
            _uut["A"] = "foo\"bar";

            CsvAssert.IsEqual(_uut, new[] { "A", @"""foo""""bar""" });
        }
Esempio n. 3
0
        public void EscapesDelimiter()
        {
            _uut.StartRow();
            _uut["A"] = "1,5";

            CsvAssert.IsEqual(_uut, new[] { "A", @"""1,5""" });
        }
        public void DictionaryToCsv()
        {
            var someDictionary = new Dictionary <string, int> {
                { "foo", 1 }, { "bar", 2 }
            };

            var actual = someDictionary.ToCsv();

            CsvAssert.IsEqual(actual, new[] { "key,value", "foo,1", "bar,2" });
        }
Esempio n. 5
0
        public void SortsByFieldName()
        {
            _uut.StartRow();
            _uut["B"] = 2;
            _uut["A"] = 1;
            _uut["Z"] = 4;
            _uut["C"] = 3;

            CsvAssert.IsEqual(_uut, new[] { "A,B,C,Z", "1,2,3,4" }, CsvBuilder.SortFields.ByName);
        }
Esempio n. 6
0
        public void HandlesMissingValues()
        {
            _uut.StartRow();
            _uut["A"] = 1;
            _uut["B"] = 2;
            _uut.StartRow();
            _uut["A"] = 3;

            CsvAssert.IsEqual(_uut, new[] { "A,B", "1,2", "3," });
        }
Esempio n. 7
0
        public void SortsByFieldNameExcludeFirstField()
        {
            _uut.StartRow();
            _uut["Header"] = 0;
            _uut["A"]      = 1;
            _uut["Z"]      = 3;
            _uut["C"]      = 2;

            CsvAssert.IsEqual(_uut, new[] { "Header,A,C,Z", "0,1,2,3" }, CsvBuilder.SortFields.ByNameLeaveFirst);
        }
Esempio n. 8
0
        public void AddsColumnsAndFields()
        {
            _uut.StartRow();
            _uut["A"] = 1;
            _uut["B"] = 2;
            _uut.StartRow();
            _uut["A"] = 3;
            _uut["B"] = 4;

            CsvAssert.IsEqual(_uut, new[] { "A,B", "1,2", "3,4" });
        }