Example #1
0
        public void TestReadWrite_Comments()
        {
            StringWriter         output = new StringWriter();
            SeparatedValueWriter writer = new SeparatedValueWriter(output);

            writer.Write(new[] { "a", "b", "c" });
            writer.WriteRaw("# Hello, world!!!", true);
            writer.Write(new[] { "d", "e", "f" });

            StringReader         input  = new StringReader(output.ToString());
            SeparatedValueReader reader = new SeparatedValueReader(input);

            reader.RecordRead += (sender, e) =>
            {
                e.IsSkipped = e.Values.Length > 0 && e.Values[0].StartsWith("#");
            };
            Assert.IsTrue(reader.Read());
            CollectionAssert.AreEqual(new[] { "a", "b", "c" }, reader.GetValues());
            Assert.IsTrue(reader.Read());
            CollectionAssert.AreEqual(new[] { "d", "e", "f" }, reader.GetValues());
            Assert.IsFalse(reader.Read());
        }