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\n" + "1,\"between \"\"quotes\"\" here\",\"with, comma\",\r\n" + "1,\"between \"\"quotes\"\" here\",\"with, comma\",\r\n" )); }
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" )); }
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" )); }
public void serialize_Customer_BOLID() { var customer = NorthwindFactory.Customer( "BOLID", "Bólido Comidas preparadas", "Martín Sommer", "Owner", "C/ Araquil, 67", "Madrid", null, "28023", "Spain", "(91) 555 22 82", "(91) 555 91 99", null); var model = new TestClass { Value = TypeSerializer.SerializeToString(customer) }; var toModel = Serialize(model); Console.WriteLine("toModel.Value: " + toModel.Value); var toCustomer = TypeSerializer.DeserializeFromString <Customer>(toModel.Value); Console.WriteLine("customer.Address: " + customer.Address); Console.WriteLine("toCustomer.Address: " + toCustomer.Address); }