-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
api-approvedAPI was approved, it can be implementedAPI was approved, it can be implementedenhancement
Description
Background and motivation
To globally exclude member names from an equivalency assertion of a complex graph, one can use the IMemberInfo overload as follows:
var ignoredPropertyNames = new[] { "Parent", "Children" };
actual.Should().BeEquivalentTo(expected, config => config
.Excluding((IMemberInfo member) => ignoredPropertyNames.Contains(member.Name)));Please add a shortcut method that enables easily adding a list of properties to be excluded throughout the graph regardless of the type they belong to.
API Proposal
public abstract class SelfReferenceEquivalencyOptions<TSelf> : IEquivalencyOptions
{
public TSelf ExcludingMemberNames(params IEnumerable<string> excludedMemberNames) =>
Excluding((IMemberInfo member) => excludedMemberNames.Contains(member.Name));
}API Usage
actual.Should().BeEquivalentTo(expected, options => options.ExcludingMemberNames("Parent", "Children"));Alternative Designs
No response
Risks
No response
Are you willing to help with a proof-of-concept (as PR in that or a separate repo) first and as pull-request later on?
No
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved, it can be implementedAPI was approved, it can be implementedenhancement