public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string nullableCode)
        {
            var subject        = new BsonJavaScriptConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScript(nullableCode);

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

            result.Should().Be(expectedResult);
        }
        public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableCode, string expectedResult)
        {
            var subject = new BsonJavaScriptConverter();
            var value   = nullableCode == null ? null : new BsonJavaScript(nullableCode);

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

            result.Should().Be(expectedResult);
        }
        public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string nullableCode)
        {
            var subject        = new BsonJavaScriptConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScript(nullableCode);

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

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

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

            action.ShouldThrow <Newtonsoft.Json.JsonReaderException>();
        }
        public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableCode, string expectedResult)
        {
            var subject = new BsonJavaScriptConverter();
            var value   = nullableCode == null ? null : new BsonJavaScript(nullableCode);

            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)
        {
            var subject = new BsonJavaScriptConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScript(nullableCode);

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

            result.Should().Be(expectedResult);
        }
        public void ReadJson_should_return_expected_result_when_using_wrapped_bson_reader(string json, string nullableCode)
        {
            var subject = new BsonJavaScriptConverter();
            var expectedResult = nullableCode == null ? null : new BsonJavaScript(nullableCode);

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

            result.Should().Be(expectedResult);
        }
        public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableCode, string expectedResult)
        {
            var subject = new BsonJavaScriptConverter();
            var value = nullableCode == null ? null : new BsonJavaScript(nullableCode);

            var result = WriteJsonUsingWrappedJsonWriter(subject, value);

            result.Should().Be(expectedResult);
        }
        public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableCode, string expectedResult)
        {
            var subject = new BsonJavaScriptConverter();
            var value = nullableCode == null ? null : new BsonJavaScript(nullableCode);

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

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

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