How to use real parameters when creating a stub method in RhinoMocks?

I want to create a stub of the following interface:

interface IUnitOfWork { void DoInTransaction(Action method); } 

In the stub object, all I want to do DoInTransaction is to run method() .

Something like:

 // pseudo-code unitOfWorkStub.Stub(x => x.DoInTransaction(method)).Do(method()) 

Is it possible to create such a stub with RhinoMocks? How can I do that?

+7
source share
1 answer

use this:

 unitOfWorkStub.Stub(x => x.DoInTransaction(Arg<Action>.Is.Anything)) .WhenCalled(x => ((Action)x.Arguments[0])()); 
+16
source

All Articles