public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string nullablePattern, string nullableOptions) { var subject = new BsonRegularExpressionConverter(); var expectedResult = nullablePattern == null ? null : new BsonRegularExpression(nullablePattern, nullableOptions); var result = ReadJsonUsingWrappedJsonReader <BsonRegularExpression>(subject, json); result.Should().Be(expectedResult); }
public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string nullablePattern, string nullableOptions) { var subject = new BsonRegularExpressionConverter(); var expectedResult = nullablePattern == null ? null : new BsonRegularExpression(nullablePattern, nullableOptions); var result = ReadJsonUsingNativeBsonReader <BsonRegularExpression>(subject, ToBson(json), mustBeNested: true); result.Should().Be(expectedResult); }
public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullablePattern, string nullableOptions, string expectedResult) { var subject = new BsonRegularExpressionConverter(); var value = nullablePattern == null ? null : new BsonRegularExpression(nullablePattern, nullableOptions); var result = WriteJsonUsingNativeBsonWriter(subject, value, mustBeNested: true); result.Should().Equal(ToBson(expectedResult)); }
public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullablePattern, string nullableOptions, string expectedResult) { var subject = new BsonRegularExpressionConverter(); var value = nullablePattern == null ? null : new BsonRegularExpression(nullablePattern, nullableOptions); var result = WriteJsonUsingWrappedJsonWriter(subject, value); result.Should().Be(expectedResult); }
public void ReadJson_should_throw_when_token_type_is_invalid() { var subject = new BsonRegularExpressionConverter(); var json = "undefined"; Action action = () => { var _ = ReadJsonUsingNativeJsonReader <BsonRegularExpression>(subject, json); }; action.Should().Throw <Newtonsoft.Json.JsonReaderException>(); }