NSubstitute:检查 DidNotReceive 异步方法

090*_*9EM 5 nsubstitute .net-core

给定一个异步方法,NSubstitute 如何检查未收到呼叫?

使用 NSubstitute,我们可以使用以下命令检查按顺序收到的异步方法(或多个):

Received.InOrder(async () =>
{
    await client.SendAsync(Arg.Any<string>())
});
Run Code Online (Sandbox Code Playgroud)

相当于什么DidNotReceive

090*_*9EM 6

我在这里创建/回答了我自己的问题,因为我发现这在 NSubstitute 中不直观。

await client.DidNotReceive().SendAsync(Arg.Any<string>());
Run Code Online (Sandbox Code Playgroud)