public void ExceedingCapacityThrows() { var bytes = new byte[] { 74, 117, 97, 110, 32, 67, 97, 114, 108, 111, 115, 32, 59, 41 }; var inner = new MemoryStream(); inner.Write(bytes, 0, bytes.Length); inner.Position = 0; var wrapper = RecordingStream.ReadRecordingStream(inner, bytes.Length - 1); var buffer = new byte[bytes.Length]; Assert.Throws <InvalidOperationException>(() => wrapper.Read(buffer, 0, bytes.Length)); }
public void TestCanReadOrCanWrite() { var inner = new MemoryStream(); var readWrapper = RecordingStream.ReadRecordingStream(inner, size: null); Assert.True(readWrapper.CanRead); Assert.False(readWrapper.CanWrite); var writeWrapper = RecordingStream.WriteRecordingStream(inner); Assert.False(writeWrapper.CanRead); Assert.True(writeWrapper.CanWrite); }
public void BytesAreReadAndRecorded() { var bytes = new byte[] { 74, 117, 97, 110, 32, 67, 97, 114, 108, 111, 115, 32, 59, 41 }; var inner = new MemoryStream(); inner.Write(bytes, 0, bytes.Length); inner.Position = 0; var wrapper = RecordingStream.ReadRecordingStream(inner, bytes.Length); var buffer = new byte[bytes.Length]; var bytesRead = wrapper.Read(buffer, 0, bytes.Length); Assert.Equal(bytes.Length, bytesRead); Assert.Equal(bytes, buffer); Assert.Equal(bytes, wrapper.RecordedBytes); }