犀牛嘲笑 - 你如何嘲笑5个电话

时间:2015-03-24 18:34:11

标签: c# rhino-mocks

我有5个特定方法的调用,我希望为这5个调用中的每一个返回不同的东西。我想在Rhino Mocks中用某种方式说出

For the 1st call return this
For the 2nd call return that

等等

这可能吗?

1 个答案:

答案 0 :(得分:1)

在每个方法存根之后使用Repeat.Once()。例如:

myMock.Stub(x => x.Method()).Return(1).Repeat.Once()
myMock.Stub(x => x.Method()).Return(2).Repeat.Once()