Can I get the parameters used while waiting in Rhino Mocks?

I configure the wait for a method call that builds and executes the request. I would like to poll the properties of the parameter used. Is it possible,

using (mocks.Record()) { Expect.Call(connection.Retrieve(SOMETHING_HERE)).Return(returnedDatay); } 

The bit that I am is the SOMETHING HERE bit.

(This is my first time we used Rhino mocks)

+4
source share
1 answer

You can set restrictions on parameters and parameter properties. The following code sets a restriction on the MyProperty property in your connection object. The layout expects MyProperty to be 42. Note that null is passed as a parameter, as it is ignored.

 Expect .Call(connection.Retrieve(null)) .IgnoreArguments() .Constraints(Property.Value("MyProperty", 42)) .Return(returnedData); 

I write this from memory, so it may not be entirely correct.


UPDATE:

Rhino Mocks version 3.5 introduces a new extension method GetArgumentsForCallsMadeOn, which allows you to check the parameters passed to defrauded objects:

http://kashfarooq.wordpress.com/2009/01/10/rhino-mocks-and-getargumentsforcallsmadeon/

+10
source

All Articles