Ejemplo n.º 1
0
        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());
            }
        }