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

Regression in 4.12.0: SetupAllProperties resets indexer setups #901

Closed
stakx opened this issue Aug 22, 2019 · 0 comments · Fixed by #902
Closed

Regression in 4.12.0: SetupAllProperties resets indexer setups #901

stakx opened this issue Aug 22, 2019 · 0 comments · Fixed by #902
Assignees
Labels
Milestone

Comments

@stakx
Copy link
Contributor

stakx commented Aug 22, 2019

Code to reproduce:

public interface IX
{
    string this[int index] { get; }
}

[Fact]
void SetupAllProperties_should_not_reset_indexer_setups()
{
    var mock = new Mock<IX>();
    mock.SetupGet(x => x[1]).Returns("value from setup");
    Assert.Equal("value from setup", mock.Object[1]);  // passes
    mock.SetupAllProperties();
    Assert.Equal("value from setup", mock.Object[1]);  // fails
}

This is caused by this line:

https://github.com/moq/moq4/blob/81d1fb24b5a9c5ceb443114b1657137501c4f9e5/src/Moq/SetupCollection.cs#L62

The filter condition should be more specific and rule out indexer accessors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant