It's a bit strange. I'm trying to stub a method that has parameters, I don't care what parameters are, so I ignore the arguments. It looks like this:
List<Foo> ignored; A.CallTo(() => fake.Method(out ignored)) .Returns(something);
This works without any problems when the cropped method is called like this:
List<Foo> target; var result = service.Method(out target);
However, this does not work when target pre-initialized. For instance:
List<Foo> target = new List<Foo>(); var result = service.Method(out target);
When I check Tag on a fake, I see that the out parameters are written as <NULL> , so I suspect that they do not match when the final target is already set to something. I tried setting ignored in my test to new List<Foo>() , and also tried A<List<Foo>>.Ignored , but none of them affected the result.
So my question is: does anyone know how to stub a method with out parameters if the value of the out parameter already has a value?
source share