Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for nested collection exclude by name string #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions AnyDiff/AnyDiff.Tests/IgnoreTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,26 @@ public void ShouldExclude_ByPropertyPathList()
Assert.AreEqual(0, diff.Count);
}

[Test]
public void ShouldExclude_NestedCollectionByName()
{
// If nested collection excluding with propertiesToExcludeOrInclude is working this test should output only 1 difference because the Child 2/Child 3 difference would be ignored. The values that are different are object1 and object2 id and the 2nd complex child name.
var basicChild = new BasicChild(1, "Basic Child");
// Notice "Child 2" at index [1]
var childrenList1 = new List<ComplexChild> { new ComplexChild(1, "Child 1", basicChild), new ComplexChild(2, "Child 2", basicChild) };
// Notice "Child 3" at index [1]
var childrenList2 = new List<ComplexChild> { new ComplexChild(1, "Child 1", basicChild), new ComplexChild(2, "Child 3", basicChild) };

// Notice id 1
var object1 = new ComplexObjectWithListChildren(1, "Name 1", childrenList1, basicChild);
// Notice id 2
var object2 = new ComplexObjectWithListChildren(2, "Name 1", childrenList2, basicChild);

var diff = object1.Diff(object2, ".Children.ChildName");
// There are 2 differences between the objects, but the difference count should be 1, because child name should be ignored.
Assert.AreEqual(1, diff.Count);
}

[Test]
public void ShouldInclude_ByPropertyList()
{
Expand Down