public void ReadCStringBytes_should_throw_when_terminating_null_byte_is_missing()
        {
            var bytes = new byte[] { 0, 97, 98 };
            var stream = new MemoryStream(bytes);
            var subject = new BsonStreamAdapter(stream);
            subject.SetLength(3);
            subject.Position = 1;

            Action action = () => subject.ReadCStringBytes();

            action.ShouldThrow<EndOfStreamException>();
        }
        public void SetLength_should_call_wrapped_stream()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var length = 1L;

            subject.SetLength(length);

            stream.Received(1).SetLength(length);
        }
        public void SetLength_should_throw_when_subject_is_diposed()
        {
            var stream = Substitute.For<Stream>();
            var subject = new BsonStreamAdapter(stream);
            var length = 1L;
            subject.Dispose();

            Action action = () => subject.SetLength(length);

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        public void SetLength_should_call_wrapped_stream()
        {
            var mockStream = new Mock<Stream>();
            var subject = new BsonStreamAdapter(mockStream.Object);
            var length = 1L;

            subject.SetLength(length);

            mockStream.Verify(s => s.SetLength(length), Times.Once);
        }