public void EndWrite_should_throw_when_subject_is_disposed()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var asyncResult = Substitute.For<IAsyncResult>();
            subject.Dispose();

            Action action = () => subject.EndWrite(asyncResult);

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        public void EndWrite_should_throw_when_subject_is_disposed()
        {
            var mockStream = new Mock<Stream>();
            var subject = new BsonStreamAdapter(mockStream.Object);
            var mockAsyncResult = new Mock<IAsyncResult>();
            subject.Dispose();

            Action action = () => subject.EndWrite(mockAsyncResult.Object);

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        public void EndWrite_should_call_wrapped_stream()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var asyncResult = Substitute.For<IAsyncResult>();

            subject.EndWrite(asyncResult);

            stream.Received(1).EndWrite(asyncResult);
        }
        public void EndWrite_should_call_wrapped_stream()
        {
            var mockStream = new Mock<Stream>();
            var subject = new BsonStreamAdapter(mockStream.Object);
            var mockAsyncResult = new Mock<IAsyncResult>();

            subject.EndWrite(mockAsyncResult.Object);

            mockStream.Verify(s => s.EndWrite(mockAsyncResult.Object), Times.Once);
        }