RhinoMocks expects a complex object as a parameter

I use RhinoMocks without problems for checking with AssertWasCalled if my method with simple parameters like Arg.Is.Equal (1), etc. was called.

However, it fails when I try to expect a complex object of my own creation, for example.

Arg<CustomClass>.Is.Equal(CustomClassInstance) 

Of course, I know well that this should not work, because the links do not match. However, my question is: how do I get it to work? How to make RhinoMocks expect an object with specific values ​​inside?

+7
source share
1 answer

You can use Arg<T>.Matches (Predicate<T> predicate) as:

 mock.AssertWasCalled (m => m.Foo (Arg<CustomClass>.Matches (c => c.Foo == CustomClassInstance.Foo)); 
+9
source

All Articles