如何使用 MVCContrib Route TestHelper 验证操作方法的参数
我有一个以分页对象作为参数的操作方法
public override ActionResult Index(Paging paging)
{
.......
return View(...);
}
那么我如何验证 url 以匹配操作方法及其参数呢?如下
Paging paging = new DefaultPaging();
"/Search".ShouldMapTo<SearchController>(action => action.Index(paging));
更新
这是路由定义的样子,Page、PageSize 和 Sort 是 Paging 类的成员
routes.MapRoute(controller.Name, string.Format("{0}/{{Page}}/{{PageSize}}/{{Sort}}", controller.Name),
controller.Index().AddRouteValues(new DefaultPaging()));
I have an action method which has pagination object as parameter
public override ActionResult Index(Paging paging)
{
.......
return View(...);
}
So how could I verify the url to match action method and it's parameter? like below
Paging paging = new DefaultPaging();
"/Search".ShouldMapTo<SearchController>(action => action.Index(paging));
Update
Here is how the route definition looks like, Page,PageSize and Sort are member of the Paging class
routes.MapRoute(controller.Name, string.Format("{0}/{{Page}}/{{PageSize}}/{{Sort}}", controller.Name),
controller.Index().AddRouteValues(new DefaultPaging()));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论