public void GetBuffer_returns_a_buffer_corresponding_to_GetNumBytesAvailable()
 {
     int window = 100;
     var streamMock = new Mock<MemoryStream>(MockBehavior.Strict);
     SetupMockStreamRead(streamMock).Returns((byte[] s, int o, int l) => 50);
     var buf = new SlidingStreamBuffer(streamMock.Object, window);
     buf.Warmup();
     streamMock.VerifyAll();
     Assert.AreEqual(buf.GetNumBytesAvailable(), buf.GetBuffer().Length);
 }
 public void GetNumBytesAvailable_when_moved_to_end_of_stream_returns_zero()
 {
     int window = 10;
     var buffer = new byte[window*2];
     for (int i = 0; i < buffer.Length; ++i) buffer[i] = (byte) (200 - i);
     var buf = new SlidingStreamBuffer(new MemoryStream(buffer), window, window);
     buf.Warmup();
     buf.MoveForward(buffer.Length);
     Assert.AreEqual(0, buf.GetNumBytesAvailable());
 }
 public void MoveForward_beyond_windowSize_with_no_more_data_in_stream_yields_NumAvailable_lower_than_windowSize()
 {
     int window = 10;
     var buffer = new byte[window*2];
     for (int i = 0; i < buffer.Length; ++i) buffer[i] = (byte) (200 - i);
     var buf = new SlidingStreamBuffer(new MemoryStream(buffer), window, window);
     buf.Warmup();
     buf.MoveForward(window + 1);
     Assert.AreEqual(window - 1, buf.GetNumBytesAvailable());
 }
 public void GetNumBytesAvailable_returns_windowSize_for_full_read()
 {
     int window = 100;
     var streamMock = new Mock<MemoryStream>(MockBehavior.Strict);
     SetupMockStreamRead(streamMock)
         .Returns((byte[] s, int o, int l) => l);
     var buf = new SlidingStreamBuffer(streamMock.Object, window);
     buf.Warmup();
     Assert.AreEqual(window, buf.GetNumBytesAvailable());
 }