Async methods return null
问题 If I try to mock a type containing an async method such as : interface Foo { Task<int> Bar(); } Then the mock's Bar method is returning null. I guess Moq is choosing default(Task<int>) as default return value for my method, which is indeed null . However Moq should rather choose something like Task.FromResult(default(int)) as default value. Can I force Moq to make async methods returning non-null Tasks ? 回答1: If someone is interested, I made an extension class which makes async methods