public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableDocument, string expectedResult)
        {
            var subject = new BsonDocumentConverter();
            var value   = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = WriteJsonUsingNativeBsonWriter(subject, value, mustBeNested: true);

            result.Should().Equal(ToBson(expectedResult));
        }
        public void ReadJson_should_return_expected_result_when_using_native_json_reader(string json, string nullableDocument)
        {
            var subject = new BsonDocumentConverter();
            var expectedResult = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = ReadJsonUsingNativeJsonReader<BsonDocument>(subject, json);

            result.Should().Be(expectedResult);
        }
        public void ReadJson_should_throw_when_token_type_is_invalid()
        {
            var subject = new BsonDocumentConverter();
            var json    = "undefined";

            Action action = () => { var _ = ReadJsonUsingNativeJsonReader <BsonDocument>(subject, json); };

            action.ShouldThrow <Newtonsoft.Json.JsonReaderException>();
        }
예제 #4
0
        public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string nullableDocument)
        {
            var subject        = new BsonDocumentConverter();
            var expectedResult = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = ReadJsonUsingWrappedJsonReader <BsonDocument>(subject, json);

            result.Should().Be(expectedResult);
        }
예제 #5
0
        public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string nullableDocument)
        {
            var subject        = new BsonDocumentConverter();
            var expectedResult = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = ReadJsonUsingNativeBsonReader <BsonDocument>(subject, ToBson(json), mustBeNested: true);

            result.Should().Be(expectedResult);
        }
예제 #6
0
        public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableDocument, string expectedResult)
        {
            var subject = new BsonDocumentConverter();
            var value   = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

            result.Should().Be(expectedResult);
        }
        public void ReadJson_should_return_expected_result_when_using_wrapped_bson_reader(string json, string nullableDocument)
        {
            var subject = new BsonDocumentConverter();
            var expectedResult = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = ReadJsonUsingWrappedBsonReader<BsonDocument>(subject, ToBson(json), mustBeNested: true);

            result.Should().Be(expectedResult);
        }
        public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableDocument, string expectedResult)
        {
            var subject = new BsonDocumentConverter();
            var value = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

            result.Should().Be(expectedResult);
        }
        public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableDocument, string expectedResult)
        {
            var subject = new BsonDocumentConverter();
            var value = nullableDocument == null ? null : BsonDocument.Parse(nullableDocument);

            var result = WriteJsonUsingNativeBsonWriter(subject, value, mustBeNested: true);

            result.Should().Equal(ToBson(expectedResult));
        }
        public void ReadJson_should_throw_when_token_type_is_invalid()
        {
            var subject = new BsonDocumentConverter();
            var json = "undefined";

            Action action = () => { var _ = ReadJsonUsingNativeJsonReader<BsonDocument>(subject, json); };

            action.ShouldThrow<Newtonsoft.Json.JsonReaderException>();
        }