示例#1
0
        public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string nullableCode, string nullableScope)
        {
            var subject        = new BsonJavaScriptWithScopeConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScriptWithScope(nullableCode, BsonDocument.Parse(nullableScope));

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

            result.Should().Be(expectedResult);
        }
示例#2
0
        public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableCode, string nullableScope, string expectedResult)
        {
            var subject = new BsonJavaScriptWithScopeConverter();
            var value   = nullableCode == null ? null : new BsonJavaScriptWithScope(nullableCode, BsonDocument.Parse(nullableScope));

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

            result.Should().Be(expectedResult);
        }
示例#3
0
        public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string nullableCode, string nullableScope)
        {
            var subject        = new BsonJavaScriptWithScopeConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScriptWithScope(nullableCode, BsonDocument.Parse(nullableScope));

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

            result.Should().Be(expectedResult);
        }
示例#4
0
        public void ReadJson_should_throw_when_token_type_is_invalid()
        {
            var subject = new BsonJavaScriptWithScopeConverter();
            var json    = "undefined";

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

            action.ShouldThrow <Newtonsoft.Json.JsonReaderException>();
        }
示例#5
0
        public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableCode, string nullableScope, string expectedResult)
        {
            var subject = new BsonJavaScriptWithScopeConverter();
            var value   = nullableCode == null ? null : new BsonJavaScriptWithScope(nullableCode, BsonDocument.Parse(nullableScope));

            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 nullableCode, string nullableScope)
        {
            var subject = new BsonJavaScriptWithScopeConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScriptWithScope(nullableCode, BsonDocument.Parse(nullableScope));

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

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

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

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

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

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

            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 BsonJavaScriptWithScopeConverter();
            var json = "undefined";

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

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