コード例 #1
0
        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());
        }
コード例 #2
0
        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);
        }