0
votes

Among the bunch of specific routes defined in my application, I use the default route to map all remaining parameterless routes:

routes.MapRoute("Default", "{controller}/{action}", new { controller = "calendar", action = "list" });

With this, I obtain for instance the following routing:

  • ~/customer/add -> controller = customer, action = add
  • ~/customer -> controller = customer, action = list
  • ~/ -> controller = calendar, action = list

The whole routing part is unit tested (using Phil Haack's method) in such that I check if the "~/customer" URL will indeed be split into controller = "customer" and action = "list".

The problem is that if I remove a controller or an action, the test will remain green since the route is still successfully mapped by the default route.

Somehow, I'd like my test to fail if the targeted controller or action are invalid. Is there a way to do this at UnitTest level?

Thanks!

1

1 Answers

1
votes

You can achieve that by using MvcContrib

Please see example here for Routes Testing http://mvccontrib.codeplex.com/wikipage?title=TestHelper#Examples