May 24, 2011 at 12:12 PM
Edited May 24, 2011 at 12:12 PM
Figured it out.
Use the Method instead of MethodWith.
For example, your mockobject interface defines a method called Print(Car someCar). You have written a matcher for matching cars called CarMatcher.
This is how your expectation can look like:
Car car = new Car("some stuff"); // This is just to give you the idea. You would probably have set this up and now want to expect that the Print method is called with a Car instance that matches what you have set up.
this.mockCar.Expects.One.Method(x => x.Print(car).With(new CarMatcher(car));
This should work just fine. Somehow, I don't like the feel of this, though. On one hand, I supply a lambda 'x => x.Print(car)' which says that the car instance that I specified above is to be passed, and on the other hand, I am setting up an matcher to
Any better way to do this?