I have simple HttpApplication class:
public class MvcApplication : HttpApplication
{
public void Application_Start()
{
// register areas
AreaRegistration.RegisterAllAreas();
// register other stuff...
}
}
My unit tests initialise HttpApplication
, invoke ApplicationStart
and verify application start-up behaviour.
This approach worked well until I had to integrate MVC areas. When AreaRegistration.RegisterAllAreas()
is invoked by a unit test, the following exception gets thrown:
System.InvalidOperationException: This method cannot be called during the application's pre-start initialization stage.
Is there a good approach for testing area initialisation logic?