【问题标题】:Nancy unit test doesn't work when requesting static content请求静态内容时,Nancy 单元测试不起作用
【发布时间】:2013-12-12 23:49:28
【问题描述】:

我有一个基于 Nancy 的 Web 项目和一个使用 MSTest 引用该 Web 项目的单元测试项目。

我已将 robots.txt 文件添加到 Web 项目的 Content 文件夹中。我在BootstrapperConfigureConventions 方法中使用nancyConventions.StaticContentsConventions.AddFile("/robots.txt", "/Content/robots.txt"); 添加了一个静态内容路径。

单元测试如下所示:

[TestMethod]
public void Get_Robotstxt_Should_Return_Status_OK()
{
    // Given
    var browser = new Browser(new Bootstrapper());

    // When
    var result = browser.Get("/robots.txt");

    // Then
    Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}

代码在部署时实际上运行良好,只是测试不起作用。

【问题讨论】:

    标签: c# unit-testing nancy


    【解决方案1】:

    robots.txt 文件很可能没有复制到测试程序集的构建输出中。确保它在那里。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-04-11
      • 2012-04-21
      • 1970-01-01
      • 2011-02-25
      • 2012-10-27
      • 2012-08-02
      • 1970-01-01
      相关资源
      最近更新 更多