-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
Description
Calling ExcludingMissingMembers/ThrowingOnMissingMembers calls ClearMatchingRules() and potentially removes an instance of MappedMemberMatchingRule.
Complete minimal example reproducing the issue
[Fact]
public void Exclusion_of_missing_members_works_with_mapping()
{
// Arrange
var subject = new { Property1 = 1 };
var expectation = new { Property2 = 2, Ignore = 3 };
// Act / Assert
subject.Should()
.NotBeEquivalentTo(expectation, opt => opt
.WithMapping("Property2", "Property1")
.ExcludingMissingMembers()
);
}
[Fact]
public void Mapping_works_with_exclusion_of_missing_members()
{
// Arrange
var subject = new { Property1 = 1 };
var expectation = new { Property2 = 2, Ignore = 3 };
// Act / Assert
subject.Should()
.NotBeEquivalentTo(expectation, opt => opt
.ExcludingMissingMembers()
.WithMapping("Property2", "Property1")
);
}Expected behavior:
Both should pass
Actual behavior:
Exclusion_of_missing_members_works_with_mapping fails with
Expected subject not to be equivalent to { Property2 = 2, Ignore = 3 }, but they are.
Versions
- Which version of Fluent Assertions are you using?
develop/ 418a405