当我尝试测试 Nancy 模块时,我得到以下信息:
StructureMap 异常代码:205 InstanceKey“Nancy.Testing.Fakes.FakeNancyModule”缺少请求的实例属性“modulePath”
这是我的测试:
public class when_a_user_logs_in_successfully
{
static Browser _browser;
static BrowserResponse _response;
Establish context = () =>
{
var bootstrapper = new BlurtsBootsrapper();
_browser = new Browser(bootstrapper); //throws exception here
};
Because of = () => _response = _browser.Get("/Login", with => with.HttpRequest());
It should_return_a_successful_response = () => _response.Body.ShouldNotBeNull();
}
这是我的 BlurtsBootstrapper:
public class BlurtsBootsrapper : StructureMapNancyBootstrapper
{
protected override void ApplicationStartup(StructureMap.IContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
container.Configure(x => x.AddRegistry<BlurtsRegistry>());
}
}