i got a class that gets by argument a delegate. This class invokes that delegate, and i want to unit test it with Moq. how do i verify that this method was called ?
exam
As of this commit Moq now supports the mocking of delegates, for your situation you would do it like so:
var fooMock = new Mock(); var a = new A(fooMock.Object);
Then you can verify the delegate was invoked:
fooMock.Verify(f => f(5), Times.Once);
Or:
fooMock.Verify(f => f(It.IsAny()), Times.Once);