Reputation: 810
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());
Upvotes: 0
Views: 974
Reputation: 13
If you want to put the method call exactly a number of times:
unitMock.Expects.Exactly (2) .Method (m => m.Convert ());
At the end you need to call:
_mockFactory.VerifyAllExpectationsHaveBeenMet ();
To make sure that if you call 2 times and not just 0 or 1.
If you want to establish exactly what data you should call the method:
unitMock.Expects.One.MethodWith (m => m.Convert ("5"));
If you want to establish what the method should return:
unitMock.Expects.One.MethodWith (m => m.Convert ("5")) WillReturn (5);
Upvotes: 1
Reputation: 682
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();
Upvotes: 0