我不知道为什么会抛出这个异常......我有一个单元测试:
[Test]
public void Should_return_status_ok_when_route_exists()
{
// Given
var bootstrapper = new DefaultNancyBootstrapper();
var browser = new Browser(bootstrapper);
// When
var result = browser.Get("/", with =>
{
with.HttpRequest();
});
// Then
Assert.AreEqual(HttpStatusCode.OK, result.StatusCode);
}
在分配浏览器变量时,异常在 Nancy Bootstrapper 基类中引发,并带有跟踪堆栈跟踪
System.InvalidOperationException : 序列包含多个元素
at System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source)
at Nancy.Bootstrapper.NancyBootstrapperBase`1.GetRootPathProvider() in NancyBootstrapperBase.cs: line 558
at Nancy.Bootstrapper.NancyBootstrapperBase`1.get_RootPathProvider() in NancyBootstrapperBase.cs: line 172
at Nancy.Bootstrapper.NancyBootstrapperBase`1.GetAdditionalInstances() in NancyBootstrapperBase.cs: line 514
at Nancy.Bootstrapper.NancyBootstrapperBase`1.Initialise() in NancyBootstrapperBase.cs: line 242
at Nancy.Testing.Browser..ctor(INancyBootstrapper bootstrapper) in Browser.cs: line 39
at Tests.Tests.Should_return_status_ok_when_route_exists() in Tests.cs: line 34