Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed ExcludeNonBrowsable in IEquivalencyAssertionOptions into sepa…
…rate properties IgnoreNonBrowsableOnSubject and ExcludeNonBrowsableOnExpectation. Updated implementations of the interface accordingly. Added new selection rule ExcludeNonBrowsableMembersRule.cs and updated SelfReferenceEquivalencyAssertionOptions.SelectionRules to inject an instance of it after AllPropertiesSelectionRule and AllFieldsSelectionRule but before explicit member selection rules. Updated the ToString implementation in SelfReferenceEquivalencyAssertionOptions.cs to consider ignoreNonBrowsableOnSubject and excludeNonBrowsableOnExpectation independently. Removed processing of options.ExcludeNonBroswable from StructuralEqualityEquivalencyStep's GetMembersFromExpectation, since this is now handled by selection rules. Added tests that exercise the situation where a non-browsable field or property is explicitly included after a call to ExcludingNonBrowsableMembers. The current logic actually doesn't provide a way to do a wildcard inclusion of all properties or fields if any Include call targeting a specific member is included, but the tests have been written so that they'll continue to effectively test this function if that changes in the future. Adjusted existing tests in SelectionRulesSpecs.cs to use IgnoringNonBrowsableMembersOnSubject where appropriate, and to verify that ExcludingNonBrowsableMembers does _not_ cause non-browsable members on the subject to be ignored.
- Loading branch information
Showing
7 changed files
with
151 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
Src/FluentAssertions/Equivalency/Selection/ExcludeNonBrowsableMembersRule.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace FluentAssertions.Equivalency.Selection | ||
{ | ||
internal class ExcludeNonBrowsableMembersRule : IMemberSelectionRule | ||
{ | ||
public bool IncludesMembers => false; | ||
|
||
public IEnumerable<IMember> SelectMembers(INode currentNode, IEnumerable<IMember> selectedMembers, MemberSelectionContext context) | ||
{ | ||
return selectedMembers.Where(member => member.IsBrowsable); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters