Inheritance: System.IO.TextReader
Example #1
0
        public void ReadToEnd()
        {
            StringReader       reader         = new StringReader("Test\r\nTest2");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual("Test\r\nTest2", scanningReader.ReadToEnd());
        }
Example #2
0
        public void LookAheadReturnsNegativeOneOnEnd()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual("Test", scanningReader.ReadToEnd());
            Assert.AreEqual(-1, scanningReader.LookAhead(0));
            Assert.AreEqual(-1, scanningReader.LookAhead(5));
        }
Example #3
0
        public void PeekWithoutLookahead()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.Peek());
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Peek());
        }
        public void ReadNormally()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', reader.Read());
            Assert.AreEqual('e', reader.Read());
            Assert.AreEqual('s', reader.Read());
            Assert.AreEqual('t', reader.Read());
            Assert.AreEqual(-1, reader.Read());
        }
Example #5
0
        public void LookAheadMany()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('t', scanningReader.LookAhead(3));
            Assert.AreEqual('e', scanningReader.LookAhead(1));
            Assert.AreEqual('s', scanningReader.LookAhead(2));
            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual("Test", scanningReader.ReadToEnd());
        }
Example #6
0
        public void ReadNormally()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', reader.Read());
            Assert.AreEqual('e', reader.Read());
            Assert.AreEqual('s', reader.Read());
            Assert.AreEqual('t', reader.Read());
            Assert.AreEqual(-1, reader.Read());
        }
Example #7
0
        public void LookAheadOne()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Read());
            Assert.AreEqual('s', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.Read());
            Assert.AreEqual('t', scanningReader.Read());
        }
Example #8
0
        public void PeekWithLookahead()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.LookAhead(2));
            Assert.AreEqual('T', scanningReader.Peek());
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Read());
            Assert.AreEqual('s', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.Peek());
            Assert.AreEqual("st", scanningReader.ReadToEnd());
        }
        public void ReadBlock()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            char[] buffer = new char[4];
            int count = scanningReader.ReadBlock(buffer, 0, 2);
            

            Assert.AreEqual(2, count);
            Assert.AreEqual("Te\0\0", new string(buffer));

            count = -1;
            count = scanningReader.ReadBlock(buffer, 2, 2);

            Assert.AreEqual(2, count);
            Assert.AreEqual("Test", new string(buffer));
        }
Example #10
0
        public void ReadBlock()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            char[] buffer = new char[4];
            int    count  = scanningReader.ReadBlock(buffer, 0, 2);


            Assert.AreEqual(2, count);
            Assert.AreEqual("Te\0\0", new string(buffer));

            count = -1;
            count = scanningReader.ReadBlock(buffer, 2, 2);

            Assert.AreEqual(2, count);
            Assert.AreEqual("Test", new string(buffer));
        }
Example #11
0
        public void ValidatePosition()
        {
            StringReader       reader         = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual(-1, scanningReader.Position);

            scanningReader.Read();
            Assert.AreEqual(0, scanningReader.Position);

            scanningReader.Read();
            scanningReader.Read();
            Assert.AreEqual(2, scanningReader.Position);

            scanningReader.Read();
            Assert.AreEqual(3, scanningReader.Position);

            scanningReader.Read();
            Assert.AreEqual(-1, scanningReader.Position);

            scanningReader.Read();
            scanningReader.Read();
            Assert.AreEqual(-1, scanningReader.Position);
        }
        public void ValidatePosition()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual(-1, scanningReader.Position);
            
            scanningReader.Read();
            Assert.AreEqual(0, scanningReader.Position);

            scanningReader.Read();
            scanningReader.Read();
            Assert.AreEqual(2, scanningReader.Position);

            scanningReader.Read();
            Assert.AreEqual(3, scanningReader.Position);

            scanningReader.Read();
            Assert.AreEqual(-1, scanningReader.Position);

            scanningReader.Read();
            scanningReader.Read();
            Assert.AreEqual(-1, scanningReader.Position);
        }
        public void ReadToEnd()
        {
            StringReader reader = new StringReader("Test\r\nTest2");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual("Test\r\nTest2", scanningReader.ReadToEnd());
        }
        public void LookAheadMany()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('t', scanningReader.LookAhead(3));
            Assert.AreEqual('e', scanningReader.LookAhead(1));
            Assert.AreEqual('s', scanningReader.LookAhead(2));
            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual("Test", scanningReader.ReadToEnd());
        }
        public void LookAheadReturnsNegativeOneOnEnd()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual("Test", scanningReader.ReadToEnd());
            Assert.AreEqual(-1, scanningReader.LookAhead(0));
            Assert.AreEqual(-1, scanningReader.LookAhead(5));
        }
        public void PeekWithoutLookahead()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.Peek());
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Peek());
        }
        public void PeekWithLookahead()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.LookAhead(2));
            Assert.AreEqual('T', scanningReader.Peek());
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Read());
            Assert.AreEqual('s', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.Peek());
            Assert.AreEqual("st", scanningReader.ReadToEnd());
        }
        public void LookAheadOne()
        {
            StringReader reader = new StringReader("Test");
            ScanningTextReader scanningReader = new ScanningTextReader(reader);

            Assert.AreEqual('T', scanningReader.LookAhead(0));
            Assert.AreEqual('T', scanningReader.Read());
            Assert.AreEqual('e', scanningReader.Read());
            Assert.AreEqual('s', scanningReader.LookAhead(0));
            Assert.AreEqual('s', scanningReader.Read());
            Assert.AreEqual('t', scanningReader.Read());
        }