public void ShouldInclude_AllChildren_NoInheritance() { var object1 = new ComplexObjectWithListChildren(1, "A string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(1, "BasicChild1")), new ComplexChild(2, "Child2", new BasicChild(2, "BasicChild2")) }, new BasicChild(1, "BasicChild1")); var object2 = new ComplexObjectWithListChildren(2, "A different string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(1, "BasicChild1")), new ComplexChild(3, "Child2", new BasicChild(2, "BasicChild2")) }, new BasicChild(1, "BasicChild1")); var diff = object1.Diff(object2, ComparisonOptions.IncludeList | ComparisonOptions.IncludeListNoInheritance | ComparisonOptions.All, x => x.Children, x => x.Children.Select(y => y.ComplexChildId) ); // only the ComplexChildId should have changed Assert.AreEqual(1, diff.Count); Assert.AreEqual(".Children.ComplexChildId", diff.First().Path); Assert.AreEqual(2, diff.First().LeftValue); Assert.AreEqual(3, diff.First().RightValue); }
public void ShouldExclude_ChildrenByPropertyList() { var object1 = new ComplexObjectWithListChildren(1, "A string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(1, "BasicChild1")), new ComplexChild(2, "Child2", new BasicChild(2, "BasicChild2")) }, new BasicChild(1, "BasicChild1")); var object2 = new ComplexObjectWithListChildren(1, "A string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(3, "BasicChild1")), new ComplexChild(2, "Child2", new BasicChild(4, "BasicChild2")) }, new BasicChild(2, "BasicChild1")); var diff = object1.Diff(object2, x => x.Name, x => x.BasicChild.BasicChildId, x => x.Children.Select(y => y.ComplexChildId), x => x.Children.Select(y => y.BasicChild.BasicChildId), x => x.Children.Select(y => y.BasicChild.Children.Select(z => z.BasicChildId)) ); Assert.AreEqual(0, diff.Count); }
public void ShouldInclude_AllChildren() { var object1 = new ComplexObjectWithListChildren(1, "A string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(1, "BasicChild1")), new ComplexChild(2, "Child2", new BasicChild(2, "BasicChild2")) }, new BasicChild(1, "BasicChild1")); var object2 = new ComplexObjectWithListChildren(2, "A different string", new List <ComplexChild> { new ComplexChild(1, "Child1", new BasicChild(1, "BasicChild1")), new ComplexChild(2, "Child2", new BasicChild(2, "BasicChild2")) }, new BasicChild(1, "BasicChild1")); var diff = object1.Diff(object2, ComparisonOptions.IncludeList | ComparisonOptions.All, x => x.Children ); Assert.AreEqual(0, diff.Count); }