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

Assign non-out/ref arg from AndDoes #61

Closed
dtchepak opened this issue Dec 28, 2018 · 0 comments
Closed

Assign non-out/ref arg from AndDoes #61

dtchepak opened this issue Dec 28, 2018 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@dtchepak
Copy link
Member

Just realised that out and ref arguments can also be set via AndDoes (in the same way they can be set from Returns). This should probably also result in a NS3005 if a non-out/ref arg is set.

        public interface ILookup { bool Lookup(string key, out int i); }

        [Fact]
        public void Test() {
            var sub = Substitute.For<ILookup>();

            sub.Lookup("blah", out Arg.Any<int>())
               .Returns(true)
               .AndDoes(x => x[0] = 45); // <-- incorrectly setting x[0] instead of x[1]. Should give NS3005

            sub.Lookup("blah", out var value);
        }
@dtchepak dtchepak added the enhancement New feature or request label Dec 28, 2018
tpodolak added a commit that referenced this issue Feb 9, 2019
Analyzing callInfo usages for AndDoes method
@tpodolak tpodolak added this to the 1.0.5 milestone Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants