public void WriteByte_WriteByteNotCalledOnInnerStream(bool delayedWriter) { var streamMock = new Mock <Stream>(); byte[] tmparr = new byte[1]; BufferedStreamWriter s = new BufferedStreamWriter(streamMock.Object, GetConfig(1, delayedWriter)); s.WriteByte(1); s.WriteByte(1); streamMock.Verify(f => f.WriteByte(It.IsAny <byte>()), Times.Never()); }
public void WriteByte_CorrectBytesAreSaved(int shadowBufferSize, int totBytes, bool delayedWriter) { byte[] inputBuffer = Enumerable.Range(1, totBytes).Select(f => (byte)f).ToArray(); byte[] destBuffer = new byte[totBytes]; MemoryStream memStream = new MemoryStream(destBuffer); using (BufferedStreamWriter s = new BufferedStreamWriter(memStream, GetConfig(shadowBufferSize, delayedWriter))) { for (int f = 0; f < totBytes; f++) { s.WriteByte(inputBuffer[f]); } } Assert.AreEqual(inputBuffer, destBuffer); }