-
Notifications
You must be signed in to change notification settings - Fork 731
Description
Description
A bit of a weird title but basically if I call myCollection.Should().BeEquivalent(expected, cfg => cfg.Excluding(i => i.SomeArray[0].SomeProperty)), the property isn't correctly excluded and I get the follow assertion error:
Expected property root[0].Items[0].Name to be "Foo", but "Bar" differs near "Bar"
Complete minimal example reproducing the issue
var expected = new A[] {
new A { Items = new List<B> { new B { Name = "Foo" } } }
};
var actual = new A[] {
new A { Items = new List<B> { new B { Name = "Bar" } } }
};
actual.Should().BeEquivalentTo(
expected,
cfg => cfg.Excluding(a => a.Items[0].Name)
);
class A
{
public string Name { get; set; }
public List<B> Items { get; set; }
}
class B
{
public string Name { get; set; }
}Expected behavior:
The excluding rule to be used and the test to pass.
Actual behavior:
The excluding rule is ignored and the test fails.
Versions
-
Which version of Fluent Assertions are you using?
v6.6.0 -
Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.1.
.NET 6
Additional Information
I believe this is a regression between v5.5.3 and v6.6.0 - I haven't (yet) nailed down which version but will update when I have.
Edit: The regression starts in v6.0.0. The last v5 has this behaving correctly.
Additionally, this only seems to affect properties behind the array in the excluded check. Properties on the same level as the array work as expected if excluded.