Skip to content

Add missing ConstraintExpression.Contain overload #1983

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
Jan 16, 2017

Conversation

polsys
Copy link
Contributor

@polsys polsys commented Jan 15, 2017

This works:

string str = "a";
Assert.That(str, Does.Contain("a"));
Assert.That(str, Does.Not.Contain("b"));

But this fails to compile (cannot convert from int to string):

int[] ints = { 2 };
Assert.That(ints, Does.Contain(2));
Assert.That(ints, Does.Not.Contain(1));

This PR adds the Contain(object) overload for consistency. The same can be achieved with at least Has.No.Member() and Does.Not.Contains(), so I don't object if this addition is considered unnecessary. This is somewhat related to #1758.

There are no test changes, since the Contain(string) overload is not tested either, as it duplicated work in Contains(), and now just calls it directly.

@CharliePoole
Copy link
Member

I'm good with this change. It makes things more consistent. Thanks for doing it.

We need one more committer to approve it before merging.

Copy link
Member

@ChrisMaddock ChrisMaddock left a comment

Choose a reason for hiding this comment

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

Sounds sensible to me. 👍 Thanks!

@ChrisMaddock ChrisMaddock added this to the 3.7 milestone Jan 16, 2017
@ChrisMaddock ChrisMaddock merged commit 4b85d8b into nunit:master Jan 16, 2017
@polsys polsys deleted the FixMissingContain branch January 16, 2017 12:57
JustinRChou pushed a commit to JustinRChou/nunit that referenced this pull request Jan 21, 2017
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.

3 participants