How do you setup a Moq setup Callback for a method with an in parameter modifier?
Say you have this:
public interface ITester
{
bool IsGood(in int value);
}
This doesn't work:
var mock = new Mock<ITester>();
mock.Setup(m => m.IsGood(It.IsAny<int>()))
.Callback<int>(v => { /* whatever */ }); // ==> runtime error
mock.Object.IsGood(42);
You get the following exception:
System.ArgumentException : Invalid callback. Setup on method with parameters (in int) cannot invoke callback with parameters (int).
What's the correct way (apart from removing the in modifier altogether ;) )?