My application was in .NET CORE 3.0 and i am upgrading it with .NET 8.0.
My integration test project use some of the config value MemoryCollection instead of AppSettings. same value i want to use in .NET 8.0 integration test project. but it always take value from appsettings.
I have configured in memory value from WebApplicationFactory class.
Below is my code.
protected override void ConfigureWebHost(IWebHostBuilder builder)
{
base.ConfigureWebHost(builder);
builder.ConfigureAppConfiguration((context, config) =>
{
config.AddInMemoryCollection(new[]
{
new KeyValuePair<string, string>("DataProtect:File", "Data/protect.pfx")
});
});
builder.ConfigureServices((context, services) =>
{
});
builder.ConfigureTestServices(services =>
{
// Mock external dependency
services.SwapService(Substitute.For<ITestService>());
});
}
In AppSettings.Development.Json
"DataProtect": {
"File": "./bin/Debug/net8/Data/protect.pfx",
"CertificatePassword": "******"
}
I want File : ‘Data/protect.pfx’ value in integration test project.