开发者

Conditional mocking using NMock

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.

  1. First call return Obj1
  2. Second call return 开发者_开发问答Obj3
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜