public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string expectedResult) { var subject = new BsonValueConverter(); var result = ReadJsonUsingWrappedJsonReader <BsonValue>(subject, json); result.Should().Be(BsonSerializer.Deserialize <BsonValue>(expectedResult)); }
public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string expectedResult) { var subject = new BsonValueConverter(); var result = ReadJsonUsingNativeBsonReader <BsonValue>(subject, ToBson(json), mustBeNested: true); result.Should().Be(expectedResult); }
public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableValue, string expectedResult) { var subject = new BsonValueConverter(); var value = nullableValue == null ? null : BsonSerializer.Deserialize <BsonValue>(nullableValue); var result = WriteJsonUsingWrappedJsonWriter(subject, value); result.Should().Be(expectedResult); }
[TestCase("{ $timestamp : { t : 1, i : 2 } }", "{ x : { $$timestamp : { t : 1, i : 2 } } }")] // note: Json.NET can't write a BsonTimestamp public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableValue, string expectedResult) { var subject = new BsonValueConverter(); var value = nullableValue == null ? null : BsonSerializer.Deserialize <BsonValue>(nullableValue); var result = WriteJsonUsingNativeBsonWriter(subject, value, mustBeNested: true); result.Should().Equal(ToBson(expectedResult)); }
private BsonValue GetBsonValueWithLayout <T>(LogEventInfo logEvent, string layoutText) { var layout = Layout.FromString(layoutText); var value = RenderLogEvent(layout, logEvent); if (string.IsNullOrEmpty(value)) { return(null); } return(BsonValueConverter.Convert <T>(value)); }
[TestCase("{ x : { $oid: \"112233445566778899aabbcc\" } }")] // note: Json.NET turns ObjectId into bytes public void ReadJson_should_return_expected_result_when_using_native_bson_reader3(string json) { // See https://github.com/nunit/nunit3-vs-adapter/issues/691 var expectedResult = "HexData(0, \"112233445566778899aabbcc\")"; var subject = new BsonValueConverter(); var result = ReadJsonUsingNativeBsonReader <BsonValue>(subject, ToBson(json), mustBeNested: true); result.Should().Be(expectedResult); }
private BsonValue GetBsonValueWithField(LogEventInfo logEvent, MongoDBLayoutField field) { var type = field.BsonType; var layout = field.Layout; if (layout == null) { return(null); } var value = RenderLogEvent(layout, logEvent); if (string.IsNullOrEmpty(value)) { return(null); } return(BsonValueConverter.Convert(value, type)); }
public void ReadJson_should_return_expected_result_when_using_native_bson_reader(string json, string expectedResult) { var subject = new BsonValueConverter(); var result = ReadJsonUsingNativeBsonReader<BsonValue>(subject, ToBson(json), mustBeNested: true); result.Should().Be(expectedResult); }
public void WriteJson_should_have_expected_result_when_using_wrapped_json_writer(string nullableValue, string expectedResult) { var subject = new BsonValueConverter(); var value = nullableValue == null ? null : BsonSerializer.Deserialize<BsonValue>(nullableValue); var result = WriteJsonUsingWrappedJsonWriter(subject, value); result.Should().Be(expectedResult); }
public void WriteJson_should_have_expected_result_when_using_native_bson_writer(string nullableValue, string expectedResult) { var subject = new BsonValueConverter(); var value = nullableValue == null ? null : BsonSerializer.Deserialize<BsonValue>(nullableValue); var result = WriteJsonUsingNativeBsonWriter(subject, value, mustBeNested: true); result.Should().Equal(ToBson(expectedResult)); }
public void ReadJson_should_return_expected_result_when_using_wrapped_json_reader(string json, string expectedResult) { var subject = new BsonValueConverter(); var result = ReadJsonUsingWrappedJsonReader<BsonValue>(subject, json); result.Should().Be(BsonSerializer.Deserialize<BsonValue>(expectedResult)); }