我正在尝试使用 MvcContrib TestHelper 流畅的路由测试 API,但我看到了奇怪的行为。.WithMethod(HttpVerb) 扩展方法似乎没有按预期执行。这是我的控制器显示 (2) 接受不同 HttpVerbs 的动作(同名):
[HttpGet]
public ActionResult IdentifyUser()
{
return View(new IdentifyUserViewModel());
}
[HttpPost]
public ActionResult IdentifyUser(IdentifyUserInputModel model)
{
return null;
}
这是应该映射到具有 [HttpPost] 属性的操作的测试:
MvcApplication.RegisterRoutes(RouteTable.Routes);
var routeData = "~/public/registration/useridentification/identifyuser"
.WithMethod(HttpVerbs.Post)
.ShouldMapTo<UserIdentificationController>(x => x.IdentifyUser(null));
即使在我的测试中指定了 POST HttpVerb,它总是路由到 HttpGet 方法。 我什至可以在我的控制器中注释掉接受 HttpPost 的动作并且仍然通过测试!
我在这里缺少什么吗?