public void Read_should_call_wrapped_stream()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var buffer = new byte[3];
            var offset = 1;
            var count = 2;
            var numberOfBytesRead = 1;
            stream.Read(buffer, offset, count).Returns(numberOfBytesRead);

            var result = subject.Read(buffer, offset, count);

            result.Should().Be(numberOfBytesRead);
            stream.Received(1).Read(buffer, offset, count);
        }
        public void Read_should_throw_when_subject_is_disposed()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var buffer = new byte[3];
            var offset = 1;
            var count = 2;
            subject.Dispose();

            Action action = () => subject.Read(buffer, offset, count);

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        public void Read_should_call_wrapped_stream()
        {
            var mockStream = new Mock<Stream>();
            var subject = new BsonStreamAdapter(mockStream.Object);
            var buffer = new byte[3];
            var offset = 1;
            var count = 2;
            var numberOfBytesRead = 1;
            mockStream.Setup(s => s.Read(buffer, offset, count)).Returns(numberOfBytesRead);

            var result = subject.Read(buffer, offset, count);

            result.Should().Be(numberOfBytesRead);
            mockStream.Verify(s => s.Read(buffer, offset, count), Times.Once);
        }