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()); } }
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); }