You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
As of right now, when you use TestServer on a Test project against an MVC application with Razor Views those are not found because ApplicationBasePath is the Test project one and not the MVC.
The solution is to change the ApplicationBasePath of the Test project to the MVC Application.
Changing the base path is not a straightforward thing to do, in terms that for every test project that needs this, one must implement IApplicationEnvironment and hook into the TestServer somehow.
I created a package at https://github.com/Bartmax/TestServerMvcHelper which hooks into WebHostingBuilder and does exactly that with one practical convention of where to look for the Application.
var builder = TestServer.CreateBuilder();
builder.UseApplicationPath("YourMvcApplication");
var server = new TestServer(builder);
I wanted to start a discussion to see if there's interest on the team for this (or similar) feature, as I think this should be provided/baked into the framework, with a maybe smarter way for application basepath discovery.