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

SetupSequence doesn't support ReturnsAsync #259

Closed
abatishchev opened this issue May 11, 2016 · 6 comments
Closed

SetupSequence doesn't support ReturnsAsync #259

abatishchev opened this issue May 11, 2016 · 6 comments

Comments

@abatishchev
Copy link
Contributor

abatishchev commented May 11, 2016

Currently ReturnsAsync() is an extension method on IReturns<TMock, Task<TResult>> and SetupSequence() is on Mock<TMock>.

Is it something you could add, please?

@kzu
Copy link
Member

kzu commented May 15, 2016

PR?

On Sat, May 14, 2016, 2:22 AM Alexander Batishchev notifications@github.com
wrote:

Bump.


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#259 (comment)

@abatishchev abatishchev reopened this May 15, 2016
@abatishchev
Copy link
Contributor Author

Sorry, closes in error, maybe pressed wrong button.
If you'll accept a PR, I'll submit one soon.

@abatishchev
Copy link
Contributor Author

abatishchev commented May 16, 2016

I struggle to get it working. Can you please take a look too? The problem is that context is generic on either TResult or Task<TResult> and I'm unable to kinda combine these two.

@Jacob-McKay
Copy link

This is what I did to get around the issue:
mock.SetupSequence(m => m.method( It.IsAny<whatever>() )) .Returns(Task.FromResult<ISomething>(new Something { Successful = false })) .Returns(Task.FromResult<ISomething>(new Something { Successful = true }));

@abatishchev
Copy link
Contributor Author

Yes, Returns(Task.FromResult<T>) is a working workaround but if you have it more than few it become ugly.

@abatishchev
Copy link
Contributor Author

abatishchev commented May 17, 2016

Let's continue discussion in the PR #261

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

3 participants