How do you pass data to startup.cs?
This is for testing integration using WebHostBuilderandTestServer
I need to transfer different data depending on Test Fixture. Therefore, you do not want to extract it from the configuration file, for example
Data will be sent to registered middleware in startup.cs
The docs seem to suggest that this should work:
var configBuilder = new ConfigurationBuilder()
.AddInMemoryCollection(new[]
{
new KeyValuePair<string, string>("key", "value"),
});
var configuration = configBuilder.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseConfiguration(configuration)
.UseStartup<Startup>()
.Build();
host.Run();
but when I check the Configuration object in startup.cs, the key is missing. And only the providers defined in startup.cs are available.
I am trying to do this in program.cs for the moment to test the concept, and then I will go over to integration tests later
Any ideas what I am doing wrong?
Is there a better way to pass data at startup?