Skip to content

Allows Is.AnyOf to be called with arrays or other collections #4356

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 23, 2023

Conversation

manfred-brands
Copy link
Member

Fixes #4355

@SeanKilleen
Copy link
Member

That's....better, yeah. 😆

/// </summary>
protected virtual string GetStringRepresentation()
protected string GetStringRepresentation(IEnumerable arguments)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Since Constraint is public, this overload technically becomes a new "public" API as a custom derived Constraint may try to call this. I usually default to protected in this case out of habit, but figured I'd ask: would private protected be wanted here instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to look up private protected because it logically didn't make sense. Since when does private mean internal?
But that is because protected internal means either derived (anywhere) or direct calls from the assembly instead of only derived classes inside the assembly

I think this can be protected in case an external Constraint has a single IEnumerable argument which by default gets formatted as just the type name.
There are at least two existing constraints: CollectionSubsetConstraint and CollectionSupersetConstraint which could benefit from this call as their current (tested against) string representation is: <s...setof System.Int32[]>

Copy link
Member

@stevenaw stevenaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done, this looks good to me. Thanks @manfred-brands
I'd like to leave it open for another team member to take a look too, just in case I'm missing anything. I left a question about member visibility

Copy link
Member

@mikkelbu mikkelbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also looks good to me, and @manfred-brands reasoning in the PR and the issue seems valid (at least he has given it more thought/examination than I have).

Copy link
Member

@OsirisTerje OsirisTerje left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too.

@OsirisTerje OsirisTerje merged commit fda616f into nunit:master Apr 23, 2023
@manfred-brands manfred-brands deleted the anyOf_Improvements branch April 24, 2023 04:43
@ivan-gurin
Copy link
Contributor

Hey how about

public AnyOfConstraint AnyOf(params object?[]? expected)
?
I want Has.All.AnyOf() :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Is.AnyOf to be called with arrays or other collections
6 participants