如果它们返回 void,我找不到使用 ref 参数存根方法的方法,如下例所示:
public interface Interface1 {
void Method1(ref int i);
}
public class Class1 {
static public void Main() {
MockRepository mockRepository = new MockRepository();
Interface1 interface1 = mockRepository.Stub<Interface1>();
int i = 1;
//SetupResult.For(interface1.Method1(ref i)).OutRef(1); Can't compile
interface1.Method1(ref i);
LastCall.Repeat.Any();
mockRepository.ReplayAll();
int j = 0;
interface1.Method1(ref j);
if(j == 1) Console.WriteLine("OK");
}
你有什么主意吗?
谢谢, 斯泰尼奥