我有一个 Web 服务,我想对其进行一些单元测试,但我不确定如何进行。任何人都可以提出任何建议吗?下面是 web 服务,它生成一个包含三个字段的对象,但仅当数据库队列中有值时。
[WebMethod]
public CommandMessages GetDataLINQ()
{
CommandMessages result;
using (var dc = new TestProjectLinqSQLDataContext())
{
var command = dc.usp_dequeueTestProject();
result = command.Select(c => new CommandMessages(c.Command_Type, c.Command, c.DateTimeSent)).FirstOrDefault();
return result;
}
}
请您参考如下方法:
您无需通过 WebService 使用数据来对其进行单元测试。您只需在您的解决方案中创建另一个项目并引用您的 WebService 项目并直接调用这些方法。
