I'm using nUnit to test the routing of my MVC2 project.
When I register my routes in Global.asax.cs, I give each route a unique name and specify its RouteData, eg:
routes.MapRoute(
"ShowRecord",
"{controller}/{id}",
new { action = "Show" },
new { id = @"^\d+$" }
);
In my unit tests I then invoke RegisterRoutes on a RouteCollection object, and inspect the resulting RouteValueDictionary against each url that I want to test. I use a mocked HttpContext for this, and everything works fine.
However, what I'd really like to know is, which named route(s) matched the supplied URL? Once my unit test has obtained the RouteData object corresponding to the URL under test, can I discover specifically which route was matched? Either by name (eg "ShowRecord" in the example above), or by its index in the RouteCollection object?