-
-
Notifications
You must be signed in to change notification settings - Fork 802
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
Missing ReturnsExtensions for Methods which returns Task #117
Comments
Just edit the source online and make a pull request from the same page. Also here's an alternative implementation:
or
|
Added missing ReturnsExtensions for Methods which returns Task devlooped#117
You can also just return a Task.Delay(0) /kzu Daniel Cazzulino | Team Lead | Xamarin for Visual Studio On Tue, Jul 1, 2014 at 4:43 PM, Alexander Batishchev <
|
There is no need for this feature. In .NET 4.5 you can just use the new members of Task: Task.Delay, Task.FromResult. In .NET 4.0, you can just install TaskHelpers.Sources, and have the same (even more!) with TaskHelpers.Completed(), TaskHelpers.FromResult() and many more. |
To me, something like |
Here's what I've got in our shared tests project: public static class MoqExtensions
{
public static IReturnsResult<TMock> ReturnsAsync<TMock>(this IReturns<TMock, Task> mock) where TMock : class
{
return mock.Returns(Task.CompletedTask);
}
public static IReturnsResult<TMock> ReturnsEmptyAsync<TMock, TResult>(this IReturns<TMock, Task<IReadOnlyCollection<TResult>>> mock) where TMock : class
{
return mock.ReturnsAsync(new TResult[0]);
}
public static ISetupSequentialResult<Task<IReadOnlyCollection<TResult>>> ReturnsEmptyAsync<TResult>(this ISetupSequentialResult<Task<IReadOnlyCollection<TResult>>> setup)
{
return setup.Returns(Task.FromResult((IReadOnlyCollection<TResult>)new TResult[0]));
}
} @kzu Worth a pull request? |
Moq library has extensions in Moq.ReturnsExtensions for mocked methods which returns Task<> but none for the one with simple Task. Can this feature be added to moq library? Here is example implementation.
The text was updated successfully, but these errors were encountered: