I am trying to use the MvcContrib TestHelper validation API, but I am seeing strange behavior. The extension method .WithMethod (HttpVerb) does not seem to execute as expected. Here my controller shows (2) actions (equally named) that accept different HttpVerbs:
[HttpGet] public ActionResult IdentifyUser() { return View(new IdentifyUserViewModel()); } [HttpPost] public ActionResult IdentifyUser(IdentifyUserInputModel model) { return null; }
And here is a test that should map the action to the [HttpPost] attribute:
MvcApplication.RegisterRoutes(RouteTable.Routes); var routeData = "~/public/registration/useridentification/identifyuser" .WithMethod(HttpVerbs.Post) .ShouldMapTo<UserIdentificationController>(x => x.IdentifyUser(null));
Despite the fact that the POST HttpVerb is specified in my test, it is always routed to the HttpGet method. I can even comment on the action taking the HttpPost in my controller and still pass the test!
Am I missing something here?
nunit asp.net-mvc-2
Danny douglass
source share