How to test database actions in asp.net core integration test?
<p>I am trying to integration test my app. </p>

<p>for example, in my <code>AbController</code> I have <code>PostAb(AbDTO abDTO)</code> method, and I want to test that calling this method will add abDTO to db.</p>

<p>now my test setup:</p>

<pre><code>    [SetUp]
    public void SetUp()
    {
        _server = new TestServer(new WebHostBuilder()
            .UseEnvironment("testing")
            .UseStartup&lt;Startup&gt;());

        _client = _server.CreateClient();
    }
</code></pre>

<p>and my test should look like:</p>

<pre><code>    [Test]
    public async Task PostAbSanity()
    {
        await _client.PostAsync("/rest/v1/Ab", new Ab{Id=1});
        _context.Abs.find(1).should().NotBeNull();
    }
</code></pre>

<p>but, how can I inject _context into test? in my app I inject it through constructors, but in tests I cant.</p>

<p>thanks!</p>