예제 #1
0
        public void TestPeekSupportReadBytePeek()
        {
            MemoryStream stream = new MemoryStream();

            for (int i = 0; i < 10; i++)
            {
                stream.WriteByte((byte)i);
            }
            stream.Seek(0, SeekOrigin.Begin);

            PeekSupportingStream peekSup = new PeekSupportingStream(stream);

            peekSup.StartPeeking();
            for (int i = 0; i < 7; i++)
            {
                Assert.AreEqual(i, peekSup.ReadByte());
            }
            peekSup.EndPeeking();

            // read the whole content after end of peeking
            for (int i = 0; i < 10; i++)
            {
                Assert.AreEqual(i, peekSup.ReadByte());
            }
        }
예제 #2
0
        public void TestEmptyPeek()
        {
            MemoryStream stream = new MemoryStream();

            for (int i = 0; i < 10; i++)
            {
                stream.WriteByte((byte)i);
            }
            stream.Seek(0, SeekOrigin.Begin);
            PeekSupportingStream peekSup = new PeekSupportingStream(stream);

            peekSup.StartPeeking();
            peekSup.EndPeeking();
            int res = peekSup.ReadByte();

            Assert.AreEqual(0, res);
        }