How can I tell Moq to return a Task?
Your method doesn’t have any callbacks so there is no reason to use .CallBack(). You can simply return a Task with the desired values using .Returns() and Task.FromResult, e.g.: MyType someValue=…; mock.Setup(arg=>arg.DoSomethingAsync()) .Returns(Task.FromResult(someValue)); Update 2014-06-22 Moq 4.2 has two new extension methods to assist with this. mock.Setup(arg=>arg.DoSomethingAsync()) .ReturnsAsync(someValue); mock.Setup(arg=>arg.DoSomethingAsync()) .ThrowsAsync(new InvalidOperationException()); Update 2016-05-05 As Seth … Read more