[英]How to use the real parameters when creating a stub method in RhinoMocks?
我想創建以下接口的存根:
interface IUnitOfWork
{
void DoInTransaction(Action method);
}
在存根對象中,我想要DoInTransaction
做的就是運行method()
。
就像是:
// pseudo-code
unitOfWorkStub.Stub(x => x.DoInTransaction(method)).Do(method())
是否可以使用RhinoMocks創建這種存根? 如何才能做到這一點?
用這個:
unitOfWorkStub.Stub(x => x.DoInTransaction(Arg<Action>.Is.Anything))
.WhenCalled(x => ((Action)x.Arguments[0])());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.