void Read_All_Position(Encoding encoding)
        {
            MemoryStream stream = new MemoryStream(encoding.GetBytes(TestString));
            PositionAwareStreamReader reader = new PositionAwareStreamReader(stream, encoding);
            char[] buffer = new char[TestString.Length];

            Assert.AreEqual(TestString.Length, reader.Read(buffer, 0, buffer.Length));
            Assert.AreEqual(TestString, new string(buffer));
            Assert.AreEqual(TestString.Length, reader.Position);
        }
        void Read_Fragment_Position(Encoding encoding)
        {
            MemoryStream stream = new MemoryStream(encoding.GetBytes(TestString));
            PositionAwareStreamReader reader = new PositionAwareStreamReader(stream, encoding);
            int charsToRead = TestString.Length / 2;
            char[] buffer = new char[charsToRead];

            Assert.AreEqual(charsToRead, reader.Read(buffer, 0, charsToRead));
            Assert.AreEqual(TestString.Substring(0, charsToRead), new string(buffer));
            Assert.AreEqual(charsToRead, reader.Position);
        }
Example #3
0
        void Read_All_Position(Encoding encoding)
        {
            MemoryStream stream = new MemoryStream(encoding.GetBytes(TestString));
            PositionAwareStreamReader reader = new PositionAwareStreamReader(stream, encoding);

            char[] buffer = new char[TestString.Length];

            Assert.AreEqual(TestString.Length, reader.Read(buffer, 0, buffer.Length));
            Assert.AreEqual(TestString, new string(buffer));
            Assert.AreEqual(TestString.Length, reader.Position);
        }
Example #4
0
        void Read_Fragment_Position(Encoding encoding)
        {
            MemoryStream stream = new MemoryStream(encoding.GetBytes(TestString));
            PositionAwareStreamReader reader = new PositionAwareStreamReader(stream, encoding);
            int charsToRead = TestString.Length / 2;

            char[] buffer = new char[charsToRead];

            Assert.AreEqual(charsToRead, reader.Read(buffer, 0, charsToRead));
            Assert.AreEqual(TestString.Substring(0, charsToRead), new string(buffer));
            Assert.AreEqual(charsToRead, reader.Position);
        }