Does not work with MVC 4 default project

Sep 3, 2012 at 5:16 AM

In the template MVC 4 project there is no longer a MyApplication.RegisterRoutes method, rather routes are registered in RouteConfig.RegisterRoutes.

The RouteTester constructor looks for the presence of the RegisterRoutes method and calls it to initialise the registrations. When the method is not found all the tests fail. There is a workaround which is of course to add the RegisterRoutes method back in for MVC 4 projects, but this is not ideal.

Really the constructor should now also check for RouteConfig.RegisterRoutes and call that if found, otherwise unfortunately this package won't get much take up with MVC4.

Jan 23, 2013 at 2:08 PM

Yes I agree. Should be updated for MVC4.

Fantastic tool, but this is becoming a pain as it has added complexity to our already messy Global.asax.

Jan 23, 2013 at 4:17 PM

There is a fork which solves this problem perfectly:   http://mvcrouteunittester.codeplex.com/SourceControl/network/forks/manzo/MVC4/changeset/89e81fe04a2f

 

Download it, compile it in release mode, and replace the original dll/xml files with the ones you've compiled. Hopefully Lee will accept the pull request and update the nuget package as well!

Oct 7 at 10:25 PM
Edited Oct 7 at 10:26 PM
wouldn't this work ? I am using MVC 5 and this project (mvcrouteunittester) works
            RouteCollection routes = new RouteCollection();
            MVCProjectNamespace.RouteConfig.RegisterRoutes(routes);
            RouteTester tester = new RouteTester(routes);