Nunit 单元测试NancyFX API-ConfigurableBootstrapper异常

Nunit 单元测试NancyFX API-ConfigurableBootstrapper异常,nunit,nancy,Nunit,Nancy,我正在尝试为我的Nancy API设置nunit测试。我有一个非常简单的结论: this.Get["/"] = _ => { return Negotiate .WithModel(" API is running") .WithStatusCode(HttpStatusCode.OK); }; 当我尝试使用此测试进行测试时: this._browser = new Browse

我正在尝试为我的Nancy API设置nunit测试。我有一个非常简单的结论:

this.Get["/"] = _ =>
       {
           return Negotiate
               .WithModel(" API is running")
               .WithStatusCode(HttpStatusCode.OK);
       };
当我尝试使用此测试进行测试时:

this._browser = new Browser(with => {
           with.Module(new IndexModule());
       });

       var result = this._browser.Get("/", with => { with.HttpRequest(); });

       Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
我收到ConfigurableBootstrapper异常,并显示消息“OhNoes”

如果我将报税表更改为:

return "API is running";
它起作用了。我想我可能在测试设置中遗漏了一些允许协商返回的内容


有人知道我做错了什么吗?谢谢。

在“哦,不”例外中会有一条线索——可能类似于

Nancy.ViewEngines.ViewNotFoundException
尝试添加

with.Header("Accept", "application/json")
或类似于您的请求设置。默认情况下,我认为测试浏览器请求HTML内容,
协商
将希望在视图中呈现这些内容。请参阅“默认响应处理器”一节中的此处