public void AssertAreAllFieldsEqual_NestedDifferentObjects_False() { var mainObj1 = new NestingGenericObject { Nested1 = new GenericObject { Prop1 = "prop1", Prop2 = "prop2" }, Nested2 = new GenericObject { Prop1 = "prop3", Prop2 = "prop4" } }; var mainObj2 = new NestingGenericObject { Nested1 = new GenericObject { Prop1 = "prop1", Prop2 = "prop2" }, Nested2 = new GenericObject { Prop1 = "prop999", Prop2 = "prop4" } }; try { AssertHelper.AssertAreAllFieldsEqual(mainObj1, mainObj2); Assert.True(false, AssertFailMissingMessage); } catch (Xunit.Sdk.TrueException ex) when(!ex.Message.Contains(AssertFailMissingMessage)) { // The assert helper has thrown an assert fail, as expected. Note that we don't want to catch the Assert.Fail() that we throw ourselves. } }
public void AssertAreAllFieldsEqual_NestedIdenticalObjects_True() { var mainObj1 = new NestingGenericObject { Nested1 = new GenericObject { Prop1 = "prop1", Prop2 = "prop2" }, Nested2 = new GenericObject { Prop1 = "prop3", Prop2 = "prop4" } }; var mainObj2 = new NestingGenericObject { Nested1 = new GenericObject { Prop1 = "prop1", Prop2 = "prop2" }, Nested2 = new GenericObject { Prop1 = "prop3", Prop2 = "prop4" } }; AssertHelper.AssertAreAllFieldsEqual(mainObj2, mainObj1); }