In my integration tests, I use a TestServer
class to work towards a test server instance for my integration tests. In RC1, I instanciated it using the following code:
var server = new TestServer(TestServer.CreateBuilder().UseStartup<Startup>());
On RC2, TestServer.CreateBuilder() was removed. Therefore, I tried to create a new TestServer using the following code:
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
The problem I'm facing is that after RC2, the runtime is unable to resolve dependencies for DI, so that it throws exceptions on the Configure method for the Startup class. The system does however start up if I start the actual server (not the test project). The exception thrown is as following:
System.Exception : Could not resolve a service of type 'ShikashiBot.IShikashiBotManager' for the parameter 'botManager' of method 'Configure' on type 'ShikashiBot.Startup'.
I'm currently using the following package for the test host: Microsoft.AspNetCore.TestHost": "1.0.0-rc2-final
I needed some changes to get your repo to work:
appsettings.sample.json
toappsettings.json
, I guess this is just because it's not in source control."buildOptions": { "copyToOutput": [ "appsettings.json" ] }
to theproject.json
of the IntegrationTests project.Verbose
toDebug
in yourappsettings.json
.But after this the integration test
EndPointsRequiresAuthorization
goes through the dependency injection, and for me it fails with an exception inShikashiBotManager
, I guess because I don't have the Postgre DB set up.For you it already fails before this, because it cannot resolve the
IShikashiBotManager
interface, right?Can you try to do a complete purge of your local repository with
git clean -xfd
(NOTE: your not commited local changes will be deleted), rebuild and try again?