Example #1
0
        public void Can_create_csv_from_Categories()
        {
            NorthwindData.LoadData(false);
            var category   = NorthwindFactory.Category(1, "between \"quotes\" here", "with, comma", null);
            var categories = new[] { category, category };
            var csv        = CsvSerializer.SerializeToCsv(categories);

            Log(csv);
            Assert.That(csv, Is.EqualTo("Id,CategoryName,Description,Picture\r\n1,\"between \"\"quotes\"\" here\",\"with, comma\",\r\n1,\"between \"\"quotes\"\" here\",\"with, comma\",\r\n"));
        }
Example #2
0
        public void Can_create_csv_from_Categories_pipe_separator()
        {
            CsvConfig.ItemSeperatorString = "|";
            NorthwindData.LoadData(false);
            var category   = NorthwindFactory.Category(1, "between \"quotes\" here", "with, comma", null);
            var categories = new[] { category, category };
            var csv        = CsvSerializer.SerializeToCsv(categories);

            Log(csv);
            Assert.That(csv, Is.EqualTo(
                            "Id|CategoryName|Description|Picture\r\n"
                            + "1|\"between \"\"quotes\"\" here\"|with, comma|\r\n"
                            + "1|\"between \"\"quotes\"\" here\"|with, comma|\r\n"
                            ));
        }
Example #3
0
        public void Can_create_csv_from_Categories_long_delimiter()
        {
            CsvConfig.ItemDelimiterString = "~^~";
            NorthwindData.LoadData(false);
            var category   = NorthwindFactory.Category(1, "between \"quotes\" here", "with, comma", null);
            var categories = new[] { category, category };
            var csv        = CsvSerializer.SerializeToCsv(categories);

            Log(csv);
            Assert.That(csv, Is.EqualTo(
                            "Id,CategoryName,Description,Picture\r\n"
                            + "1,between \"quotes\" here,~^~with, comma~^~,\r\n"
                            + "1,between \"quotes\" here,~^~with, comma~^~,\r\n"
                            ));
        }