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

Not picking up ambiguous arg matchers properly #31

Closed
dtchepak opened this issue Oct 11, 2010 · 2 comments
Closed

Not picking up ambiguous arg matchers properly #31

dtchepak opened this issue Oct 11, 2010 · 2 comments
Labels
bug Reported problem with NSubstitute behaviour

Comments

@dtchepak
Copy link
Member

public interface ICalculator { int Add(int a, int b); }

[Test] public void a_test() {
    var calculator = Substitute.For<ICalculator>();
    calculator.Add(0, Arg.Any<int>()).Returns(5);
    Assert.AreEqual(5, calculator.Add(0, 1));        
}

This test fails at the Assert.AreEqual because it gets 0, not 5.

I expected to get an AmbiguousArgumentsException because it could not tell which argument the Arg.Any<int>() arg matcher applied to. Either that or have the test pass because I called Add(0, 1) which I stubbed to give 5.

@dtchepak
Copy link
Member Author

Repro test case.

@AnthonyEgerton
Copy link
Member

Fixed by 8d8aebf

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.
This issue was closed.
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