开发者

RhinoMocks expecting complex object as a parameter

开发者 https://www.devze.com 2023-02-18 02:13 出处:网络
I use RhinoMocks without problems for checking using AssertWasCalled if my method was called with simple parameters such as Arg.Is.Equal(1) etc.

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

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

Arg<CustomClass>.Is.Equal(CustomClassInstance)

Of course, I am well aware that this should not work because references don't match. However, my question is: how do I make it work? How can make RhinoMocks expect an object 开发者_高级运维with certain values inside?


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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号