title: Routes in AspNetCore.TestHost depend on Startup.cs location?
body: <p>I am trying to test my ASP.NET Core Web Application with Microsoft.AspNetCore.TestHost. It works fine this way (result has status 200):</p>
  
  <pre><code>var server = new TestServer(new WebHostBuilder().UseStartup&lt;Startup&gt;());
  var client = server.CreateClient();
  var result = await client.GetAsync(someRequestUrl);
  </code></pre>
  
  <p>In this case the real Startup class from the API project is used.</p>
  
  <p>However, I don't want to use the real Startup class in my integration test. The main reason is the need to mock some stuff that gets wired during application startup. For example, the database server to be used. It can be done in a very elegant way by defining a virtual method in Startup.cs:</p>
  
  <pre><code>public virtual void SetupDbContext(IServiceCollection services)
  {
      services.AddDbContext&lt;TbsDb&gt;(options =&gt;
          options.UseSqlServer("someConnectionString"));
  }
  </code></pre>
  
  <p>Then I create a new class, which inherits from the original Startup class and overrides this method to use Sqlite, in-memory database or whatever:</p>
  
  <pre><code>public override void SetupDbContext(IServiceCollection services)
  {
      services.AddDbContext&lt;TbsDb&gt;(
          options =&gt; options.UseSqlite("someConnectionString"));
  }
  </code></pre>
  
  <p>This also works well with TestHost if the new class is in the same API project.</p>
  
  <p>Obviously, I don't want this class which is used for testing to be there. But if I move it to integration tests project and create a TestServer there, the same test fails because the result has status 404. Why is it happening? It still inherits from the Startup class, which is in the API project. Thus I expect all the routes to work the same no matter where the TestStartup class is. Can it be solved somehow?</p>