Let\'s say I have the following class and an interface it depends on:
public class MyController
{
private IRepository _repository;
public MyControlle
You will need to return something; async Task
methods cannot ever return null
.
The T
doesn't matter. You could declare a static readonly Task SuccessTask = Task.FromResult<object>(null);
as a helper constant if you want. I have similar constants in my AsyncEx library.
If you are targeting .NET Framework 4.6 or later, you can now use .Returns(Task.CompletedTask)
instead which is slightly shorter.