In my integration tests, I use the TestServer class to work with a test server instance for my integration tests. In RC1, I used it using the following code:
var server = new TestServer(TestServer.CreateBuilder().UseStartup<Startup>());
In RC2, TestServer.CreateBuilder () has been removed. So I tried to create a new TestServer using the following code:
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
The problem I ran into is that after RC2, the runtime cannot resolve dependencies for DI, so it throws exceptions from the Configure method for the Startup class. However, the system starts if I run a real server (and not a test project). The exception is the following:
System.Exception : Could not resolve a service of type 'ShikashiBot.IShikashiBotManager' for the parameter 'botManager' of method 'Configure' on type 'ShikashiBot.Startup'.
I am currently using the following package for a test host: Microsoft.AspNetCore.TestHost": "1.0.0-rc2-final
Martin
source share