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

Add missing sequence setup methods ReturnsAsync and ThrowsAsync for ValueTask<TResult> #599

Closed
stakx opened this issue Feb 28, 2018 · 0 comments

Comments

@stakx
Copy link
Contributor

stakx commented Feb 28, 2018

The sequence setup API is incomplete: it is missing the ReturnsAsync and ThrowsAsync method overloads for ValueTask<TResult>:

public interface IHaveAsyncMethods
{
    Task<int> GetIntTask();
    ValueTask<int> GetIntValueTask();
}

var mock = new Mock<IHaveAsyncMethods>();

mock.Setup(m => m.GetIntTask()).ReturnsAsync(1);
mock.Setup(m => m.GetIntValueTask()).ReturnsAsync(2);
mock.SetupSequence(m => m.GetIntTask()).ReturnsAsync(3);
mock.SetupSequence(m => m.GetIntValueTask()).ReturnsAsync(4);  // missing method
mock.Setup(m => m.GetIntTask()).ThrowsAsync(new Exception("5"));
mock.Setup(m => m.GetIntValueTask()).ThrowsAsync(new Exception("6"));
mock.SetupSequence(m => m.GetIntTask()).ThrowsAsync(new Exception("7"));
mock.SetupSequence(m => m.GetIntValueTask()).ThrowsAsync(new Exception("8"));  // missing method

For completeness and consistency, these should be added.

(This perhaps shouldn't happen right now since we've decided to freeze Moq 4's API for the time being, while the initial release for Moq 5 is being finalized.)

/cc @kzu

@stakx stakx changed the title Sequence setups are missing ReturnsAsync and ThrowsAsync overloads for ValueTask<TResult> Add missing sequence setup methods ReturnsAsync and ThrowsAsync for ValueTask<TResult> Feb 28, 2018
@stakx stakx closed this as completed in #626 Jun 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant