예제 #1
0
        public void CharacterStreamCloseTest()
        {
            StringReaderHarness harness = new StringReaderHarness("Test");
            CharacterScanner sut = new CharacterScanner(harness);

            sut.Close();

            Assert.AreEqual(true, harness.DisposeInvoked, "Dispose should have been invoked");
            Assert.AreEqual(true, sut.IsEOF(), "Should now indicate EOF");
        }
예제 #2
0
        public void CharacterStreamConstructorTest_StringReader()
        {
            StringReader testInput = new StringReader("Test");
            StreamLocation expectedLocation = new StreamLocation(0, 1, 1);

            CharacterScanner sut = new CharacterScanner(testInput);

            Assert.AreEqual(false, sut.IsEOF(), "Should not be at EOF");
            Assert.AreEqual(true, sut.HasNext(), "Should have next");
            Assert.AreEqual(expectedLocation, sut.Location);
            Assert.AreEqual('T', sut.Peek());
        }
예제 #3
0
        public void CharacterStreamIsEOFHasNextTest_NotEOF()
        {
            string testInput = "a";
            bool expectEOF = false;
            StreamLocation expectedLocation = new StreamLocation(0, 1, 1);

            CharacterScanner sut = new CharacterScanner(testInput);
            sut.Start();

            Assert.AreEqual(expectEOF, sut.IsEOF(), "EOF unexpected");
            Assert.AreEqual(!expectEOF, sut.HasNext(), "HasNext expected");
            Assert.AreEqual(expectedLocation, sut.Location);
        }
예제 #4
0
        public void CharacterStreamIsEOFHasNextTest_AtEOF()
        {
            string testInput = "a";
            bool expectEOF = true;
            StreamLocation expectedLocation = new StreamLocation(1, 1, 2);

            CharacterScanner sut = new CharacterScanner(testInput);
            sut.Start();
            sut.Consume();

            Assert.AreEqual(expectEOF, sut.IsEOF(), "EOF expected");
            Assert.AreEqual(!expectEOF, sut.HasNext(), "HasNext unexpected");
            Assert.AreEqual(expectedLocation, sut.Location);
        }