如何使用Arg<>来自返回()中的Stub()的匹配器?

时间:2011-06-10 09:34:07

标签: c# rhino-mocks

这是我想做的事情:

_service.Stub(s => s.Method(Arg<Dto>.Is.Anything)).Return(new OtherDto { Parent = #My Arg# });

如何用Arg替换#My Arg#?如果有可能吗?

由于

1 个答案:

答案 0 :(得分:3)

Func<Dto, OtherDto> returnOtherDto = dto => new OtherDto { Parent = dto };
_service
    .Stub(s => s.Method(Arg<Dto>.Is.Anything))
    .Do(returnOtherDto);