Stubbing Task returning method in async unit test

前端 未结 2 1025
闹比i
闹比i 2021-01-01 12:00

Let\'s say I have the following class and an interface it depends on:

public class MyController
{
    private IRepository _repository;
    public MyControlle         


        
2条回答
  •  攒了一身酷
    2021-01-01 12:51

    If you are targeting .NET Framework 4.6 or later, you can now use .Returns(Task.CompletedTask) instead which is slightly shorter.

提交回复
热议问题