Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support returning different results from stub method calls #358

Open
chrisalexander opened this issue Jan 22, 2015 · 1 comment
Open

Support returning different results from stub method calls #358

chrisalexander opened this issue Jan 22, 2015 · 1 comment

Comments

@chrisalexander
Copy link

RhinoMocks allows for the ability to return different objects the second, third, fourth etc. time that a method is called. This is particularly useful when you are mocking a factory for use in the class under test, for example:

Factory = MockRepository.GenerateStub<IFactory>();
Factory.Stub(f => f.Create(Arg<string>.Is.Anything)).Return(Object1).Repeat.Once();
Factory.Stub(f => f.Create(Arg<string>.Is.Anything)).Return(Object2).Repeat.Once();

This will mean Factory.Create(string.Any) will return Object1 the first time it is called, and Object2 the second time.

Is there potential for support this in Machine.Fakes? Thanks!

@SimonHohenadl
Copy link

It looks like the other mocking frameworks support this as well:
http://nsubstitute.github.io/help/multiple-returns/
https://github.com/Moq/moq4/wiki/Quickstart
https://github.com/FakeItEasy/FakeItEasy/wiki/Specifying-return-values

So, it should be possible to implement this in Machine.Fakes. The interesting part is how to design the API for it and whether all frameworks can be accommodated.

@robertcoltheart robertcoltheart transferred this issue from machine/machine.specifications.fakes Jan 8, 2019
@robertcoltheart robertcoltheart added this to the 2.0.0 milestone Jun 12, 2019
@robertcoltheart robertcoltheart modified the milestones: 2.0.0, 3.0.0 Sep 28, 2020
@robertcoltheart robertcoltheart modified the milestones: 3.0.0, 2.0.0 Dec 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants