模拟 silverlight 套接字
我正在使用 Moq 库来模拟套接字的行为。
我的第一个问题是套接字没有接口,但我提取了一个接口,并且我打算使用一个实现相同接口的适配器。
我正在尝试模拟套接字已连接的情况,但是 Connected 属性没有公共集(并且不应该有公共集)。
你会如何绕过它?我应该手动创建自己的模拟套接字吗?
还有其他选择吗?
I am using the Moq library to mock the socket's behaviour.
My first problem was that socket had no interface but I exctracted an interface and I intend to use an adapter which implements the same interface.
I am trying to simulate a situation where the socket is connected, however the Connected property has no public set (and it shouldn't have one).
How would you go around it? Should I just create my own mock socket manually?
Is there another option?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
寻找正确的语法。应该是:
Fond the right syntax. It should be:
我想不出什么时候我发现有必要嘲笑二传手。如果您希望套接字显示为已连接,请模拟其已连接属性以返回“true”(假设它是布尔值)。
也许可以发布更多关于您试图通过模拟实现的目标的信息?
I can't think of any time when I have found a need to to mock a setter. If you want the socket to appear connected, mock its connected property to return "true" (assuming it's boolean).
Maybe post a little more about what you are trying to accomplish with the mock?