c# - How to mock function returning void task -
i have function
public task dosomethingasync(); which want mock testing purposes.
what right way implement return value of such method. if return task<int> or something, use task.fromresult<int>(5);
i
public async void dosomethingasync() { //implementation } this lacks await operator , (at least resharper) underlined.
what correct way return task here?
all need return task , (surprise! :-)) task<t> derives task, it a task. see reference.
so return bool (or else):
return task.fromresult(true);
you return completed task using:
return task.completedtask;
(note: above available of .net 4.6)
Comments
Post a Comment