Verification method with Delegate parameter in Moq

Using Moq to generate Stub and Mocks in my unit tests, I have a case where I want to verify that a method is being called that takes a Delegate parameter. I don't care about the specific delegate setting. I just want to make sure that the method is actually called. The method is as follows:

public interface IInvokerProxy{ void Invoke(Delegate method); ... } 

In my tests, I would like to do something like this:

 invokerProxyMock.Verify( proxy => proxy.Invoke( It.IsAny<Delegate>)); 

This currently gives me an error. Argument "1": cannot convert from "method group" to "System.Delegate". Does anyone know if this is possible?

+4
source share
1 answer

I believe you are missing parentheses on It.IsAny<Delegate>() .

+5
source

Source: https://habr.com/ru/post/1306681/


All Articles