public void ReadBsonType_should_throw_when_value_is_invalid(int n)
        {
            var bytes = new byte[] { (byte)n };

            using (var memoryStream = new MemoryStream(bytes))
            using (var stream = new BsonStreamAdapter(memoryStream))
            {
                Action action = () => stream.ReadBsonType();

                action.ShouldThrow<FormatException>();
            }
        }
        public void ReadBsonType_should_return_expected_result(int n, BsonType expectedResult)
        {
            var bytes = new byte[] { (byte)n };

            using (var memoryStream = new MemoryStream(bytes))
            using (var stream = new BsonStreamAdapter(memoryStream))
            {
                var result = stream.ReadBsonType();

                result.Should().Be(expectedResult);
            }
        }
        public void ReadBsonType_should_throw_when_at_end_of_stream()
        {
            using (var memoryStream = new MemoryStream())
            using (var stream = new BsonStreamAdapter(memoryStream))
            {
                Action action = () => stream.ReadBsonType();

                action.ShouldThrow<EndOfStreamException>();
            }
        }
        public void ReadBsonType_should_throw_when_value_is_invalid(int n)
        {
            var bytes = new byte[] { (byte)n };

            using (var memoryStream = new MemoryStream(bytes))
            using (var stream = new BsonStreamAdapter(memoryStream))
            {
                Action action = () => stream.ReadBsonType();

                var hexBsonType = string.Format("{0:x2}", n);
                var expectedMessage = $"Detected unknown BSON type \"\\x{hexBsonType}\". Are you using the latest driver version?";
                action.ShouldThrow<FormatException>().WithMessage(expectedMessage);
            }
        }