Closed
Description
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);
}