Await a Async Void method call for unit testing

前端 未结 8 1519
北荒
北荒 2020-12-04 17:25

I have a method that looks like this:

private async void DoStuff(long idToLookUp)
{
    IOrder order = await orderService.LookUpIdAsync(idToLookUp);   

             


        
8条回答
  •  清歌不尽
    2020-12-04 18:01

    Change your method to return a Task and you can use Task.Result

    bool res = configuration.InitializeAsync(appConfig).Result;
    Assert.IsTrue(res);
    

提交回复
热议问题