public void TestFailure_from_long_string_should_produce_diff() { var obj1 = new PObject { Field = "Item", Property = 420, Value = new PValueObject(), }; var obj2 = new PObject { Field = "Different Item", Property = 999, }; var subj = new MemberwiseEqualMatcher <PObject>(obj1); var failure = TestMatcherLocalizer.Failure(subj, obj2); Assert.NotNull(failure.UserData.Diff); var diff = failure.UserData.Diff.ToString().Split(new [] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); Assert.Equal(new [] { "@@@ -1,5 +1,5", " {", "- Property = 420", "+ Property = 999", "@@@ -2,6 +2,6", " Property = 420", " Value = PValueObject { }", "- Field = Item", "+ Field = Different Item", }, diff); // last line contains } which is removed }
public void Matches_should_detect_same_reference() { var sameReference = new PObject(); var subj = new MemberwiseEqualMatcher <PObject>( sameReference ); Assert.True(subj.Matches(sameReference)); }
public void Matches_should_detect_nominal() { var obj1 = new PObject { Field = "Item", Property = 420, Value = new PValueObject(), }; var obj2 = new PObject { Field = "Item", Property = 420, Value = new PValueObject(), }; var subj = new MemberwiseEqualMatcher <PObject>( obj1 ); Assert.True(subj.Matches(obj2)); }