开发者

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

开发者 https://www.devze.com 2023-02-17 09:36 出处:网络
I want to create a stub of the following interface: interface IUnitOfWork { void DoInTransaction(Action method);

I want to create a stub of the following interface:

interface IUnitOfWork
{
   void DoInTransaction(Action method);
}

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

Something lik开发者_运维问答e:

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

Is it possible to create this kind of a stub with RhinoMocks? How can this be done?


use this:

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

精彩评论

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