title: XUnit DI through overridden Startup file (.net core)
body: <p>I have build a WebAPI and apart from my tests running on Postman I would like to implement some Integration/Unit tests.</p>
  
  <p>Now my business logic is very thin, most of the time its more of CRUD actions, therefore I wanted to start with testing my Controllers.</p>
  
  <p>I have a basic setup. Repository pattern (interfaces), Services (business logic) and Controllers. 
  The flow goes Controller (DI Service) -> Service (DI Repo) -> Repo Action!</p>
  
  <p>So what I did was override my Startup file to change into a in memory database and the rest should be fine (I would assume) Services are added, repos are added and now I am pointing into a in memory DB which is fine for my basic testing.</p>
  
  <pre><code>namespace API.UnitTests
  {    
      public class TestStartup : Startup
      {
          public TestStartup(IHostingEnvironment env)
              : base(env)
          {
  
          }
  
          public void ConfigureTestServices(IServiceCollection services)
          {
              base.ConfigureServices(services);
              //services.Replace&lt;IService, IMockedService&gt;();
          }
  
          public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
          {
              base.Configure(app, env, loggerFactory);
          }
  
          public override void SetUpDataBase(IServiceCollection services)
          {
              var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = ":memory:" };
              var connectionString = connectionStringBuilder.ToString();
              var connection = new SqliteConnection(connectionString);
  
              services
                  .AddEntityFrameworkSqlite()
                  .AddDbContext&lt;ApplicationDbContext&gt;(
                      options =&gt; options.UseSqlite(connection)
                  );
          }
      }
  }
  </code></pre>
  
  <p>I wrote my first test, but the DatasourceService is not there:</p>
  
  <blockquote>
    <p>The following constructor parameters did not have matching fixture data: DatasourceService datasourceService</p>
  </blockquote>
  
  <pre><code>namespace API.UnitTests
  {
      public class DatasourceControllerTest
      {
          private readonly DatasourceService _datasourceService; 
  
          public DatasourceControllerTest(DatasourceService datasourceService)
          { 
              _datasourceService = datasourceService;            
          }
  
          [Xunit.Theory,
          InlineData(1)]
          public void GetAll(int companyFk) {
              Assert.NotEmpty(_datasourceService.GetAll(companyFk));
          }
      }
  }
  </code></pre>
  
  <p>What am I missing? </p>