哪些类具有 Moles 可以重定向的方法?
我见过使用 Moles 重定向 DateTime.Now
的示例,但是当我尝试重定向 System.Net.Sockets.TcpClient.GetStream
时,我无法生成相应的 MTcpClient
出现在 Intellisense 上。
Moles 方法可以重定向的类数量是否有限?我是否遗漏了任何步骤?
I've seen samples using Moles to redirect DateTime.Now
but when I tried to redirect System.Net.Sockets.TcpClient.GetStream
I couldn't make the corresponding MTcpClient
appear on Intellisense.
Is there a limited number of classes which methods Moles can redirect? Is there any step that I missed?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,它是 System.Net.Sockets.Moles.MTcpClient,不要忘记 Moles 命名空间。
其次,在模拟 Core.dll 时似乎有一个怪癖:以通常的方式(通过右键单击解决方案资源管理器中的引用)为此程序集添加 .moles 文件后,您需要将其修改为如下所示:
否则您可能会出现构建错误,如本问题中所述。
First, it's
System.Net.Sockets.Moles.MTcpClient
, don't forget theMoles
namespace.Second, there seems to be a quirk when mocking Core.dll: after adding the .moles file for this assembly the usual way (by right-clicking the reference in Solution Explorer) you need to modify it to look like this:
or else you might get build errors as described in this question.