public void TestDeserialize() { CsvSerializer <CsvItem> serializer = new CsvSerializer <CsvItem>(); //New Serializer TextReader reader = new StringReader(CSV); //Create a Stream with Csv Text IEnumerable <CsvItem> csvItems = serializer.DeSerialize(reader); //Deserialize Csv Text CollectionAssert.AreEqual(csvItems.ToList(), CSVItems.ToList()); }
public void TestDeSerializeAndSerialize() { CsvSerializer <CsvItem> serializer = new CsvSerializer <CsvItem>(); //New Serializer TextReader reader = new StringReader(CSV); //Create a Stream with Csv Text IEnumerable <CsvItem> csvItems = serializer.DeSerialize(reader); //Deserialize Csv Text TextWriter writer = new StringWriter(); //Create a new Stream to write Csv Text to serializer.Serialize(writer, csvItems); //Serialize Items back to Csv string s = writer.ToString(); Assert.AreEqual <string>(writer.ToString(), CSV); }