0
,如果他们在下面的例子返回void,因为我无法找到一个方法来存根与参考参数的方法:如何存根的方法返回与裁判争论无效犀牛
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");
}
你有什么理念?
谢谢, 施特尼奥
它的工作原理!非常感谢你。 – stenio 2012-02-17 08:14:54
无论如何,对于一个在ref/out参数中返回一些东西的方法来说,这是相当多的语法糖。我想知道一个陈述式的方法会不会更好,不是吗? – stenio 2012-02-17 17:25:18
我可能不会改变它,但它不是我的图书馆。 :) – 2012-02-17 17:39:11