Skip to content
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

It.Is Overload taking a T not a Func #532

Closed
BlythMeister opened this issue Nov 24, 2017 · 5 comments
Closed

It.Is Overload taking a T not a Func #532

BlythMeister opened this issue Nov 24, 2017 · 5 comments

Comments

@BlythMeister
Copy link
Contributor

Rather than having to keep writing a Func to check equality
Using similar logic to the It.IsIn but with just 1 value

Suggest using the same logic as It.Is but as well as a Func, allow just an object and perform a comparison.

@stakx
Copy link
Contributor

stakx commented Nov 24, 2017

I'm afraid I don't quite understand. Could you explain this in a different way, or make a concrete example?

If you expect a very specific value, you don't need an matcher (It) at all. Simply specify the concrete value:

// do not do this:
mock.Verify(m => m.Foo(It.Is<int>(i => i == 42)));

// do this instead:
mock.Verify(m => m.Foo(42));

@BlythMeister
Copy link
Contributor Author

BlythMeister commented Nov 24, 2017

oh...you can do that....can you mix concrete value and "It" functions?
I would like to do

mock.Verify(m => m.Foo(10, It.Is<string>(i => i.StartsWith("hello"))));

@stakx
Copy link
Contributor

stakx commented Nov 24, 2017

Of course. Don't forget to take a look at the quickstart over in the wiki, it demonstrates how to use the most commonly used features. ;-)

@stakx stakx closed this as completed Nov 24, 2017
@BlythMeister
Copy link
Contributor Author

@stakx sorry :(
i couldn't see any example of mixing concreate and not concreate values.
Previous frameworks i used was either all concreate or all function type.

Thanks for your quick response!

@stakx
Copy link
Contributor

stakx commented Nov 24, 2017

No worries! :)

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

No branches or pull requests

2 participants