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);
 }
        public void TestPeekSupportMulitplePeek() {
            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();

            // now read something, then peek anew
            // read the whole content after end of peeking
            for (int i = 0; i < 3; i++) {
                Assert.AreEqual(i, peekSup.ReadByte());
            }

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

            // now read the rest of the stream
            for (int i = 3; i < 10; i++) {
                Assert.AreEqual(i, peekSup.ReadByte());
            }
        }
        public void TestPeekSupportReadArrayNoPeek() {
            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);
            byte[] result = new byte[10];
            peekSup.Read(result, 0, 10);

            for (int i = 0; i < 10; i++) {
                Assert.AreEqual(i, result[i]);
            }
        }
        public void TestPeekSupportReadByteNoPeek() {
            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);
            for (int i = 0; i < 10; i++) {
                Assert.AreEqual(i, peekSup.ReadByte());
            }
        }