Is it possible to assign an out
/ref
parameter using Moq (3.0+)?
I've looked at using Callback()
, but Action<>
does not support ref parameters because it's based on generics. I'd also preferably like to put a constraint (It.Is
) on the input of the ref
parameter, though I can do that in the callback.
I know that Rhino Mocks supports this functionality, but the project I'm working on is already using Moq.
Best Answer
For 'out', the following seems to work for me.
I'm guessing that Moq looks at the value of 'expectedValue' when you call Setup and remembers it.
For
ref
, I'm looking for an answer also.I found the following QuickStart guide useful: https://github.com/Moq/moq4/wiki/Quickstart