检查接来电()进行异步方法 [英] Check calls Received() for async method

查看:152
本文介绍了检查接来电()进行异步方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行下面的code:

When I run the following code:

[Test]
public async Task Can_Test_Update()
{
    var response = await _controller.UpdateAsync(Guid.NewGuid());
    response.Valid.Should().BeTrue();

    _commands.Received().UpdateAsync(
        Arg.Is<Something>(
            l => l.Status == Status.Updated)); 
}

如果我增加等待preceding了 _commands.Received()。UpdateAsync ,它抛出一个空引用异常。我怎样才能阻止这种情况的发生,或者是的await 没有必要?

If I add "await" preceding the "_commands.Received().UpdateAsync", it throws a null reference exception. How can I stop this happening, or is await not necessary?

推荐答案

我这里找到了答案

I found an answer here.

Received.InOrder(async () =>
{
    await _Commands.Received().UpdateAsync(Arg.Is<Lobby>(l => l.Status == Status.Updated));
});

这篇关于检查接来电()进行异步方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆