RhinoMocks Stub 返回真实实例
我正在尝试使用 RhinoMocks 来删除第三方组件。第三方组件如下所示。
public class connection
{
public connection(string host,int port)
{}
public void Submit(message msg)
{}
}
public class message
{
public message(string recipient)
{}
{
当我尝试使用存根时,它会返回对象的实际实例,并且如果我使用有效的主机和端口,我的消息将实际发送。如果我不使用有效的主机或端口,连接对象上的构造函数将引发异常。我不想要一个真实的物体,我只想要一个存根。我缺少什么?下面是我的代码。
Connection con = MockRepository.GenerateStub<Connection>("host", 25);
Message msg = new Message("[email protected]");
msg.AddRecipient(new Recipient("[email protected]"));
con.Submit(msg);
I'm trying to use RhinoMocks to stub out a third party component. The third party component looks like the following.
public class connection
{
public connection(string host,int port)
{}
public void Submit(message msg)
{}
}
public class message
{
public message(string recipient)
{}
{
When I attempt to use a stub it instead returns an actual instance of the object and my message will actually be sent if I use a valid host and port. If I don't use a valid host or port the constructor on the connection object throws an exception. I don't want a real object I just want a stub. What am I missing? Below is my code.
Connection con = MockRepository.GenerateStub<Connection>("host", 25);
Message msg = new Message("[email protected]");
msg.AddRecipient(new Recipient("[email protected]"));
con.Submit(msg);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论