如何使用 Rhino Mocks/Out 和 Ref 引數
外觀
兩者out和ref引數都支援。
在Expect語句的末尾,新增.OutRef(outOrRefParam0, outOrRefParam1,...)如下所示。
int theRef = 42;
int theOut = 0;
Expect.Call(obj.MyMethod(ref theRef, 0, out theOut)).Return(True).OutRef(13, 666);
或者,如果您使用的是 lambda 風格的期望
obj.Expect(x => x.MyMethod(ref theRef, 0, out theOut)).Return(True).OutRef(13, 666);
中的變數/物件OutRef()與方法呼叫的順序相同,忽略任何不是out或ref.