Unit testing ASP.NET MVC 2 routes with areas bails out on AreaRegistration.RegisterAllAreas()

Posted by Sandor Drieënhuizen on Stack Overflow See other posts from Stack Overflow or by Sandor Drieënhuizen
Published on 2010-04-26T18:39:11Z Indexed on 2010/04/26 18:43 UTC
Read the original article Hit count: 884

I'm unit testing my routes in ASP.NET MVC 2. I'm using MSTest and I'm using areas as well. When I call AreaRegistration.RegisterAllAreas() however, it throws this exception:

System.InvalidOperationException: System.InvalidOperationException: This method cannot be called during the application's pre-start initialization stage..

OK, so I reckon I can't call it from my class initializer. But when can I call it? I don't have an Application_Start in my test obviously.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about asp.net-mvc-2