From bf447a2c4638592b85aadf500303d12402758eb2 Mon Sep 17 00:00:00 2001 From: Dennis Doomen Date: Sun, 6 Mar 2022 21:10:37 +0100 Subject: [PATCH] SAVEPOINT --- .../MemberMatchingSpecs.cs | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Tests/FluentAssertions.Equivalency.Specs/MemberMatchingSpecs.cs b/Tests/FluentAssertions.Equivalency.Specs/MemberMatchingSpecs.cs index 990000bce1..358ab0ace7 100644 --- a/Tests/FluentAssertions.Equivalency.Specs/MemberMatchingSpecs.cs +++ b/Tests/FluentAssertions.Equivalency.Specs/MemberMatchingSpecs.cs @@ -428,6 +428,38 @@ public void The_member_name_on_a_nested_type_mapping_must_be_a_valid_member() .Throw() .WithMessage("*does not have member NonExistingProperty*"); } + + [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") + ); + } internal class ParentOfExpectationWithProperty2 {