我有一个 COM+ 接口的包装类,我需要模拟它。
这是 Socket 接口上该方法的签名
int MakeRequest(object ServiceId, object Host, object Port,
object Request, ref object pResponse);
我正在使用 Moq 来尝试模拟它,就像这样
object pResponse = String.Empty;
var socket = new Mock<Socket>();
socket.Setup(x => x.MakeRequest(It.IsAny<int>(), It.IsAny<string>(),
It.IsAny<int>(), It.IsAny<string>(),
ref pResponse))
.Returns((int i, string s, int ii, string ss, object o) =>
{
o = "Response";
return 0;
});
但是对于 Returns 中的 'o' 参数,我得到
The value passed to the method is never used because it is overwritten in the
method body before being read
我错过了什么?