public void WithWrongCtorParameter() { var actual = new WithWrongCtorParameter("meh"); var expectedJson = "{\"Name\":\"meh\"}"; var exceptions = new[] { Assert.Throws<AssertException>(() => JsonSerializerAssert.Equal(expectedJson, actual)), Assert.Throws<AssertException>(() => JsonSerializerAssert.Equal(expectedJson, actual, this.serializerSettings, JsonAssertOptions.Verbatim)) }; var expectedMessage = " Simple roundtrip failed. Source is not equal to roundtripped.\r\n" + " AssertException: Found this difference between expected and actual:\r\n" + " expected.<Name>k__BackingField: meh\r\n" + " actual.<Name>k__BackingField: null"; foreach (var exception in exceptions) { Assert.AreEqual(expectedMessage, exception.Message); } }
public void ThrowsWithWrongCtorParameter() { var actual = new WithWrongCtorParameter("meh"); var ex = Assert.Throws<AssertException>(() => JsonSerializerAssert.Roundtrip(actual)); var expectedMessage = " Simple roundtrip failed. Source is not equal to roundtripped.\r\n" + " AssertException: Found this difference between expected and actual:\r\n" + " expected.<Name>k__BackingField: meh\r\n" + " actual.<Name>k__BackingField: null"; Assert.AreEqual(expectedMessage, ex.Message); }