开发者

Verify method with Delegate parameter in Moq

开发者 https://www.devze.com 2022-12-26 18:25 出处:网络
Using Moq for generation of Stubs and Mocks in my unit tests, I have a case where I want to Verify that a method that takes a Delegate parameter is called. I don\'t care about the particular Delegate

Using Moq for generation of Stubs and Mocks in my unit tests, I have a case where I want to Verify that a method that takes a Delegate parameter is called. I don't care about the particular Delegate parameter supplied I just want to make sure that the method is in fact called. The 开发者_StackOverflow中文版method looks like this:

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

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


I believe you're missing the parentheses on It.IsAny<Delegate>().

0

精彩评论

暂无评论...
验证码 换一张
取 消