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

Recursive mocks don't work with argument matching #142

Closed
thalesmello opened this issue Nov 12, 2014 · 1 comment
Closed

Recursive mocks don't work with argument matching #142

thalesmello opened this issue Nov 12, 2014 · 1 comment
Milestone

Comments

@thalesmello
Copy link

I believe the expected behaviour would be for argument matching to work with recursive mocks. To illustrate my point, the example below fails.

public interface INameHolder
{
    string Name { get; }
}

public interface IFoo
{
    INameHolder Foo(int index);
}

[TestFixture]
public class TestSet
{
    [Test]
    public void BrokenTest()
    {
        var foo = Mock.Of<IFoo>(f => 
            f.Foo(It.Is<int>(i => i == 1)).Name == "One" &&
            f.Foo(It.Is<int>(i => i == 2)).Name == "Two");
        Assert.AreEqual("One", foo.Foo(1).Name);
        Assert.AreEqual("Two", foo.Foo(2).Name);
    }
}

// Output was:

// String lengths are both 3.
// Strings differ at index 0.
// expected: <"One">
//  but was: <"Two">
// ------------^
@stakx
Copy link
Contributor

stakx commented Jul 13, 2018

Closing this, this problem will be tracked in #643 (together with a couple other related issues).

@stakx stakx closed this as completed Jul 13, 2018
@stakx stakx added this to the 4.11.0 milestone Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants