i wonder if someone is able to help me with my problem. I have to stub a method which is able to perform conditional mocking. In short, i like the stub function to return different objects of the same class depending on when it is called.
e.g.
- First call return Obj1
- Second call return 开发者_开发问答Obj3
- Third call return Obj7
...
Does anyone know how to do this with NMock?
I think you'd be better off just writing the code to return an object based on the number of times it is called, rather than looking to the testing frameworks you're using for a solution to this issue.
So, if you had a "ObjectFactory" method of similar, you could keep a count of the number of times it's been called, and depending on the call number, return the appropriate object.
精彩评论