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

Re-entrant sub creation causes LastCallRouter to be incorrectly cleared #26

Open
dtchepak opened this issue Sep 15, 2010 · 1 comment
Open
Labels
bug Reported problem with NSubstitute behaviour

Comments

@dtchepak
Copy link
Member

dtchepak commented Sep 15, 2010

Setting a Returns() within a Returns() leads to global LastCallRouter being incorrect. May need to look at using a stack for LastCallRouter so we can handle this.

Example of bug:
sub.SomeCall().Returns(CreateASub2());
...
ISub2 CreateASub2() {
var sub2 = Substitute.For();
sub2.OtherCall().Returns(3); // <--- Problem here
}

Working example thanks to Xerx:
http://github.com/xerxesb/NSubstitute/commit/e9e2e3d2cedf2319045ebf9c529cee890b0e061d

public void Should_set_both_calls_to_return_the_specified_values()

dtchepak added a commit to dtchepak/NSubstitute that referenced this issue Jun 2, 2011
Incorrectly resolving arg matchers with default args (nsubstitute#31)
Reentrant setting of return values (nsubstitute#26)
Cleaned up code tokens from previous documentation approach.
robdmoore added a commit to robdmoore/NSubstitute that referenced this issue Dec 29, 2012
…g and have broken lot's of stuff

Furthermore, if it did work it wouldn't across multiple threads
However, it might spark an idea for other people...
@robdmoore
Copy link
Contributor

@dtchepak I've referenced this from a commit above. It's very naive/wrong and quite likely no help at all, but thought it was worth pushing in case it sparked an idea for you ;)

robdmoore added a commit to robdmoore/NSubstitute that referenced this issue Dec 29, 2012
…ach to fix nsubstituteGH-77

In order to allow for this approach to work correctly, nsubstituteGH-26 will need to be fixed
robdmoore added a commit to robdmoore/NSubstitute that referenced this issue Dec 29, 2012
This commit should probably be reverted if nsubstituteGH-26 is fixed and the ability to mock .Equals, .GetHashCode and .ToString is added or if partial mocking support is added (nsubstituteGH-93)

This is essentially reverting these two commits:
    SHA-1: 78a2348
    SHA-1: 754dccc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reported problem with NSubstitute behaviour
Projects
None yet
Development

No branches or pull requests

2 participants