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

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

            action.ShouldThrow<ObjectDisposedException>().And.ObjectName.Should().Be("BsonStreamAdapter");
        }
        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 ReadCStringBytes_should_return_expected_result(byte[] bytes, string expectedResult)
        {
            var stream = new MemoryStream(bytes);
            var subject = new BsonStreamAdapter(stream);

            var result = subject.ReadCStringBytes();

            result.Array.Skip(result.Offset).Take(result.Count).Should().Equal(bytes.Take(bytes.Length - 1));
            subject.Position.Should().Be(bytes.Length);
        }