8000 ExcludingMembersNamed(params string[] memberNames) · Issue #182 · AwesomeAssertions/AwesomeAssertions · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
ExcludingMembersNamed(params string[] memberNames) #182
Open
@weitzhandler

Description

@weitzhandler

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 ExcludingMembersNamed(params string[] memberNames) =>
        Excluding((IMemberInfo member) => memberNames.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?

Yes, please assign this issue to me.

Metadata

Metadata

Assignees

Labels

api-approvedAPI was approved, it can be implementedenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0