Search code examples
unit-testingnmockexpectations

How to test if a method was called using nmock3?


I'm trying trying to set the expectation that a method will be called. But when I write the lambda expresion inside the Method method, I get an error because I'm not passing the parameters. I don't care about the instance of the parameters, I only want to know if the method was called. Like the "It.IsAny" from Moq

What should I do?

The C# code: unitMock.Expects.One.Method(m=>m.Convert());


Solution

  • I don't know if this question is still actual. In any case, try to give any parameters to Convert method (just stubs) and add WithAnyArguments.

    unitMock.Expects.One.Method(m=>m.Convert("")).WithAnyArguments();