0

I have 5 calls to a particular method and I wanted to return different things for each of those 5 calls. I wanted some way in Rhino Mocks to say

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

and so on

Is this possible?

Sachin Kainth
  • 45,256
  • 81
  • 201
  • 304
  • 2
    It's been a while since I've used Rhino mocks, but I believe during the "record" phase you just call it 5 times, specifying the desired value for each call... then in the "replay" phase it will do the right thing. – Jon Skeet Mar 24 '15 at 18:39
  • Possible duplicate: http://stackoverflow.com/questions/10720908/rhinomocks-mocking-a-method-whose-return-value-changes-even-when-passed-the-s – dugas Mar 24 '15 at 18:40

1 Answers1

1

Just use Repeat.Once() after each method stub. For example:

myMock.Stub(x => x.Method()).Return(1).Repeat.Once()
myMock.Stub(x => x.Method()).Return(2).Repeat.Once()
Kapol
  • 6,383
  • 3
  • 21
  • 46