Search code examples
.net-corensubstitute

NSubstitute: Checking DidNotReceive async method


Given an async method, how can NSubstitute check a call was not received?

With NSubstitute, we can check a async method (or many) were received in order using:

Received.InOrder(async () =>
{
    await client.SendAsync(Arg.Any<string>())
});

What is the equivalent for DidNotReceive?


Solution

  • I created/answered my own question here because I found this unintuitive in NSubstitute.

    await client.DidNotReceive().SendAsync(Arg.Any<string>());