Last active
August 29, 2015 14:15
-
-
Save johnmmoss/18fcfd1a880b4ffe1ed4 to your computer and use it in GitHub Desktop.
Rhino Mock Async Considerations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void AsyncExamples() | |
{ | |
// Async controller actions have to be called asyn: | |
await controller.Create(model); | |
// Async methods return a task, so use Task.FromResult: | |
_apiClient.Stub(x => x.GetCustomersAsync(Arg<long>.Is.Anything)) | |
.Return(Task.FromResult(new List<Customer>())); | |
// If the method returns just Task and not Task<T> use true/null/1: | |
_file.Stub(x => x.SavePostedFile(Arg<HttpPostedFileBase>.Is.Anything)) | |
.Return(Task.FromResult(true)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment