Exemple #1
0
        public void Read()
        {
            Stream        stream  = NewStream();
            List <String> lines   = new List <String> ();
            VisitingLines visitor = new VisitingLines(lines);

            new LineReader(Encoding.UTF8).Read(stream, visitor);
            Assert.IsFalse(visitor.EmptyLinesDetected());
            Assert.AreEqual(2, visitor.Lines.Count);
            Assert.IsTrue(visitor.Lines.Contains("line1"));
            Assert.IsTrue(visitor.Lines.Contains("line2"));
        }
Exemple #2
0
        public void ReadEmptyLines()
        {
            MemoryStream stream = new MemoryStream();
            StreamWriter writer = new StreamWriter(stream, Encoding.UTF8);

            writer.Write("line1");
            writer.WriteLine();
            writer.WriteLine();
            writer.Write("line2");
            writer.WriteLine();
            writer.Flush();
            stream.Position = 0;

            List <String> lines   = new List <String> ();
            VisitingLines visitor = new VisitingLines(lines);

            new LineReader(Encoding.UTF8).Read(stream, visitor);

            Assert.IsTrue(visitor.EmptyLinesDetected());
            Assert.AreEqual(2, visitor.Lines.Count);
            Assert.IsTrue(visitor.Lines.Contains("line1"));
            Assert.IsTrue(visitor.Lines.Contains("line2"));
            Assert.AreEqual(1, visitor.EmptyLines.Count);
        }