我尝试将一些值传递给httpserver。 这是我的班级如何为类创建对象?
public interface ICommandRestClient
{
IRestResult Send(IMessageEnvelope envelope);
}
public class CommandRestClient : ICommandRestClient
{
private readonly string _serverAddress;
/// <summary>
/// Use to configure server address
/// </summary>
/// <param name="serverAddress">Configured serveraddress</param>
public CommandRestClient(string serverAddress)
{
_serverAddress = serverAddress;
}
public IRestResult Send(IMessageEnvelope envelope)
{
//do
}
}
及其工作。现在我试着为Send
方法写一些Xunit测试类。为此,我需要创建一个对象来访问CommandRestClient
类。但我没有serverAddress
值。我想通过强化地址值或不通过serverAddress
来为CommandRestClient
类创建一个对象。请帮我 谢谢。
做一个适当的值了(单或工厂)为无论你在CommandRestClient执行测试。如果测试*使用* ICommandRestClient,那么你可能会嘲笑(并且完全忘记serverAddress)。 – user2864740
您的主题不反映您的帖子。 – BDR