-
-
Notifications
You must be signed in to change notification settings - Fork 798
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
adds ReturnAsync extention method that accepts a Func<TResult> #297
Conversation
{ | ||
return mock.Returns(() => | ||
{ | ||
var tcs = new TaskCompletionSource<TResult>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not return Task.FromResult(value())
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That works as well (at least it passes the tests). I was just trying to be consistent with the method used in the extension methods that were already there. Not sure if there is an advantage/disadvantage either way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like Task.FromResult() is probably the "newer" way to go.
http://stackoverflow.com/questions/21256110/task-fromresult-vs-taskcompletionsource-setresult
…ult rather than create a TaskCompletionSource
I had just started implementing this too, when I found this PR :) I've extended it with implementations for |
Far better to have a single PR than to have to pick a "winner" 😉 On Fri, Nov 4, 2016, 2:36 AM Tomas Lycken notifications@github.com wrote:
/kzu from mobile |
Done :) When joeenzminger#1 merges, it should show up here; if you have comments or suggestions for improvement, feel free to raise them there or here. |
T4-generated overloads for ReturnsAsync(Func<T1, T2, ... TResult> value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
No description provided.