I have a class that has a create method, passing into it a POCO entity. What I want to happen is that I attach a delegate to the method call like so:
stubObject.Stub(Function(i) i.Create(Arg(of MyObject).Is().Anything))) _
.Return(True)
What I want to do is to take the instance of the parameter passed to Create and run a custom action. I thought Do() with a delegate would do the trick, but I can't get RhinoMocks 3.6 (.NET 4) to allow me to enter a parameters.
Where am I doing wrong? I can't do this:
stubObject.Stub(Function(i) i.Create(Arg(of MyObject).Is().Anything))) _
.Return(True) _
.Do(Sub(i) ...)
Thanks.
I think what you want is the "WhenCalled" option. See this SO question for an example of how it can be used to grab the arguments passed to the mocked call.