使用moq或rhino模拟或其他方式模拟出参数 [英] Mock an out parameter with moq or rhino mock or something else

查看:89
本文介绍了使用moq或rhino模拟或其他方式模拟出参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用NMock2,但在尝试将模拟传递给构造函数时遇到TypeLoadExceptions,也看到TypeMock可以做到,但要花80美元.

I tried with NMock2 but I get TypeLoadExceptions when trying to pass the mocks into the constructor, also I saw TypeMock can do that but it costs 80$

推荐答案

我发现自己可以用Moq做到这一点,就像这样:

I found out myself, you can actually do that with Moq, it's like this:

var info = new Info { stuff = 1 };

textReader.Setup(o => o.Read<CandidateCsv>("", out info));

就这样:)

这篇关于使用moq或rhino模拟或其他方式模拟出参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆