如何使用 Rhino 存根返回带有 ref 参数的 void 的方法
如果方法返回 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");
}
你有什么想法吗?
谢谢, 斯泰尼奥
I can't find a way to stub methods with ref arguments if they return void, as in the following example:
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");
}
Do you have any idea?
Thanks,
Stenio
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Rhino Mocks 3.5 有一个新的约束接口,替换了 .OutRef() 等。请参阅文档:
Rhino Mocks 3.5 has a new interface for constraints, replacing .OutRef() and others. See the documentation: