当我运行以下代码时:

[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));
}

如果在“await”之前添加“_commands.Received().UpdateAsync”,则会引发空引用异常。我该如何阻止这种情况发生,还是不需要await

最佳答案

我找到了答案here

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

09-19 06:49