Use ItExpr.IsNull rather than a null argument value, as it prevents proper method lookup

When setting up an IProtectedMock, you should use Moq.Protected.ItExpr instead of Moq.It.

Here is the corrected implementation of what I was trying to do in my question:

_innerHandler.Protected()
             .Setup<Task<HttpResponseMessage>>("SendAsync", ItExpr.IsAny<HttpRequestMessage>(), ItExpr.IsAny<CancellationToken>())
             .ReturnsAsync(responseMessage);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)