我正在尝试使用参数测试模块(以下仅是我试图解决问题的代码)
public class StuffModule : NancyModule
{
public StuffModule() : base("/Stuff")
{
Get["/All/"] = parameters =>
{
string str = parameters.one;
return Response.AsJson(str);
};
}
}
private Browser _browser;
[SetUp]
public void SetUp()
{
var module = new StuffModule(null);
var mock = new Mock<IRecipeExtractor>();
var bootstrapper = new ConfigurableBootstrapper(
with => with.Dependency(mock.Object)
);
_browser = new Browser(bootstrapper);
}
[Test]
public void Can_extract_recipe_as_json()
{
var result = _browser.Get("/Stuff/All/", with =>
{
with.HttpRequest();
with.Query("one", "yes_one");
});
Assert.That(result.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}
运行上面的代码时,我的参数变量中什么也没有。一些提示?