-
Notifications
You must be signed in to change notification settings - Fork 732
Collections containing nulls do not compare equivalent #1139
Copy link
Copy link
Closed
Labels
Description
Description
Collections containing nulls do not always appear to compare equivalent.
Complete minimal example reproducing the issue
{
var actual = new int?[] { null, 1 };
actual.Should().BeEquivalentTo(new int?[] { 1, null }); // passes
actual.Should().BeEquivalentTo(new int?[] { null, 1 }); // passes
}
{
var actual = new int?[] { 1, null };
actual.Should().BeEquivalentTo(new int?[] { 1, null }); // passes
actual.Should().BeEquivalentTo(new int?[] { null, 1 }); // passes
}
{
var actual = new object[] { null, 1 };
actual.Should().BeEquivalentTo(new object[] { 1, null }); // passes
actual.Should().BeEquivalentTo(new object[] { null, 1 }); // passes
}
{
var actual = new object[] { 1, null };
actual.Should().BeEquivalentTo(new object[] { 1, null }); // passes
actual.Should().BeEquivalentTo(new object[] { null, 1 }); // FAILS
}Expected behavior:
I expect all 8 of the very similar assertions to succeed. Should I?
Actual behavior:
8th assertion fails with: Expected item[0] to be <null>, but found 1.
Versions
- Which version of Fluent Assertions are you using? - 5.9.0
- Which .NET runtime and version are you targeting? E.g. .NET framework 4.6.1 or .NET Core 2.0. - .Net Framework 4.7.2
Reactions are currently unavailable