public void CanCheckHasNextLine()
        {
            string input =
                @"First line
4453
Last line";

            using (var s = new TextScanner(input))
            {
                // verified the following with a java sample.
                Assert.That(s.HasNextLine(), Is.True);

                Assert.That(s.NextLine(), Is.EqualTo("First line"));
                Assert.That(s.ToString(), Contains.Substring("position=12"));

                Assert.That(s.HasNextLine(), Is.True);
                Assert.That(s.NextDouble(), Is.EqualTo(4453.0));
                Assert.That(s.ToString(), Contains.Substring("position=16"));

                Assert.That(s.HasNextLine(), Is.True);
                Assert.That(s.NextLine(), Is.EqualTo(""));
                Assert.That(s.ToString(), Contains.Substring("position=18"));

                Assert.That(s.HasNextLine(), Is.True);
                Assert.That(s.NextLine(), Is.EqualTo("Last line"));
                Assert.That(s.HasNextLine(), Is.False);
                Assert.Catch(() => s.NextLine());
            }
        }
        public void CanSkipBlankLines()
        {
            string input =
                @"word

words
";

            using (var s = new TextScanner(input))
            {
                Assert.That(s.FindInLine(@"^\w+$"), Is.EqualTo("word"));
                Assert.That(s.FindInLine(@"^\w+$"), Is.EqualTo("words"));
                Assert.That(s.HasNextLine(), Is.False);
            }
        }
        public void CanSkipLines()
        {
            string input =
                @"First Line, second statement,
Second Line, fourth statement
";

            using (var s = new TextScanner(input)
                           .UseDelimiter(@",\s*"))
            {
                Assert.That(s.Next(), Is.EqualTo("First Line"));
                Assert.That(s.NextLine(), Is.EqualTo(", second statement,"));
                Assert.That(s.Next(), Is.EqualTo("Second Line"));

                Assert.That(s.FindInLine(@"^[a-z, ]+$"), Is.EqualTo(", fourth statement"));

                Assert.That(s.HasNextLine(), Is.False);

                // there are no more line endings, so the following should throw
                Assert.Catch <InvalidOperationException>(() => s.NextLine());
            }
        }