Test method XyzUnitTest.TestSomething threw exception: System.Runtime.Remoting.RemotingException: ByRef value type parameter cannot be null.
It turns out that this is caused by not having a return value in the expectation when returning a primitive:
The line of tested code that was failing:
int id = this.Foo.GetId(arg1, arg2, arg3);
The expectation that was causing the failure in the test code was:
Need to be changed to:
I think this is especially important as a (non nullable) int is being returned so the proxy is treating it as byref, hence it can not be null. This may have been missed if it was returning a object as a null object can be returned in this scenario.