Closed Pavel-Teplitsky closed 5 years ago
Yes, it's a limitation of .Net MVC.
This error This method cannot be called during the application's pre-start initialization phase
is the 'known issue' from the read-me:
Simple Injector's [assembly: WebActivator.PostApplicationStartMethod(...)] injection can cause problems with the ASP.Net hosting enviroment. You can remove the assembly level injector and call your setup from Global.aspx to solve this.
I can't see Simple Injector or similar in your stack trace, but if you have any [assembly:...
type bindings this can cause the issue.
I don't know of any work-arounds that preserve the MVC view information that the test framework gives.
I have another project at https://github.com/i-e-b/Huygens that is less prone to these kind of errors, but it's a bit heavier and takes more setup. It also loses the server-side data (such as view models).
Sorry about that. I wish Microsoft would make their frameworks more test friendly.
hi again, Than kyou for such uick responce - will continue investigation.
Hi, just in case if anybody will face similar issue or will need to test request status codes for MVC project - suggested project https://github.com/i-e-b/Huygens works well and provide a solution for such tests.
Hi, I'm getting the same error ... does that mean that this framework will not work at all with my solution? I'm not quite sure what you mean by ' ... it's a limitation of .Net MVC'.
I'm using Owin.Security and Identity.Owin and see on a closed issue you recommend Microsoft.Owin.Selfhost, but I also see a nuget package Microsoft.AspNet.TestHost.
Which is better for testing MVC6 web apps? Particularly I have controller extension methods that make Mocking the controller difficult due to tight dependencies. Thanks.
This library can't host MVC6 or Owin projects, sorry. The MVC frameworks in general have not been designed to allow integration testing. This tool tries to work around these shortcomings, but it doesn't work in all cases.
Hi, When I tried to use AppHost.Simulate http://prntscr.com/lt2oqa it fails with such exception: http://prntscr.com/lt2p6r
Solution description: MVC project placed inside the "src" folder in the solution root and I just want to check status code if to call one of the viewes.
Thank you