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

ArgumentNullException on trying to mock indexer setter with more than single index argument #695

Closed
idigra opened this issue Sep 20, 2018 · 0 comments

Comments

@idigra
Copy link
Contributor

idigra commented Sep 20, 2018

See following repro:

int x = default(int);
int y = default(int);
int result = default(int);

var mock = new Mock<IFoo>();
mock.SetupSet(f => f[3, 13] = It.IsAny<int>())
    .Callback(new Action<int, int, int>((x_, y_, result_) =>
              {
                  x = x_;
                  y = y_;
                  result = result_;
              }));

mock.Object[3, 13] = 2;
Assert.Equal(3, x);
Assert.Equal(13, y);
Assert.Equal(2, result);

The issue is a result of the if and explicitly marked with TODO in the code (file src\Moq\Mock.cs):

https://github.com/moq/moq4/blob/22cce9c3f5a7e6a66f079ad719a7e415636430bb/src/Moq/Mock.cs#L670-L677

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

2 participants