I'm trying to use code such as the following in my unit tests,
/* Test setup code */
_routes = RouteTable.Routes;
MvcApplication.RegisterRoutes(_routes); //set up the routes as they would be in actual application
/* test code */
Expression<Func<SearchController, ActionResult>> actionFunc;
actionFunc = action => action.Results("x", 3, null);
RouteTestingExtensions.Route(
"~/Search/Results?searchText=x"
).ShouldMapTo<SearchController>(actionFunc);
The problem is, this is failing with "Expected Results by was Results?searchText=x"
Does anyone have a solution which would allow me to test that a URL (with query string) resolves to the correct controller, action and arguments?
FYI, I don't have an explicit route setup in Global.asax.cs, as the default route works for the actual app - it just doesn't work in this test.