Since I have converted my WCF methods to Async, my unit tests have failed, and I can\'t figure out the correct syntax to get them to work.
Cllient proxy class
DoSomething
returns null
instead of returning a Task
, and so you get an exception when awaiting it. You need to specify when building the mock that it should return a Task
.
In this case it seems that you can simply return an already completed task using Task.FromResult
so the mock setup should look like this:
this._mockService.Setup(...).Returns(Task.FromResult(false));
Beginning with the next version of .Net (4.6) you can use Task.CompletedTask
like this:
this._mockService.Setup(...).Returns(Task.CompletedTask);