Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AssertWasCalled in rhino mocks

I have an object under test that makes a fairly complicated call to a data access object. IT looks something like

object.DoSomething(somestring,someObject,someOtherObject,someOtherOtherObject)

In my test structure I have a mocked version of object and I want to test that Dosomething got called with somestring == "value1" and someObject.porpertyA == "value2".

I can't use the simple AssertWasCalled() overload because I don;t know about (or care about) someOtherObject. I notice another overload that takes an an action for setup constraints, but I've never seen it used.

like image 792
captncraig Avatar asked Jul 01 '09 16:07

captncraig


1 Answers

Piece of cake:

yourstub.AssertWasCalled(
             x => x.DoSomething(
                Arg<string>.Is.Equal("value1"), 
                Arg<someObjectType>.Is.Equal(value2), 
                Arg<someOtherObjectType>.Is.Anything,   <======== NOTE THIS!
                Arg<someOtherOtherObjectType>.Is.Equal(value3)
             )
);
like image 95
Stop Putin Stop War Avatar answered Nov 04 '22 21:11

Stop Putin Stop War