© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•14mo ago•
77 replies
MetallixBrother

✅ Overriding IConfigurationManager.GetSection for integration tests in .NET 8 Minimal API

Hi all,

In my application, I am optionally configuring Azure App Configuration. This is achieved by checking whether or not an endpoint has been provided in the configuration via
IConfigurationManager
IConfigurationManager
(see code below).

So far in my integration tests, I'm using
WebApplicationFactory
WebApplicationFactory
to modify the services to external services.

The problem that I'm encountering is that the value for the options are populated in
appsettings.Development.json
appsettings.Development.json
. Ideally, I'd like to remove it from configuration prior to attempting to see if the endpoint is present. However, the approached that I've tried so far haven't yielded results;

- If I create a custom
WebApplicationFactory
WebApplicationFactory
and override
ConfigureWebHost
ConfigureWebHost
to specify
AppConfig:Endpoint
AppConfig:Endpoint
to null, it stops attempting to connect to Azure App Configuration, but then it fails validation of the option.
- The configuration occurs before
WebApplicationFactory.ConfigureTestServices
WebApplicationFactory.ConfigureTestServices
is called, so any manipulation of the option there would fail.
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

[FromForm] isn't available in .NET 6 for minimal API.
C#CC# / help
4y ago
Writing integration tests for .net core endpoints with authentication
C#CC# / help
3y ago
❔ Writing tests for Minimal API that calls KeyVault and Azure
C#CC# / help
3y ago
[SOLVED] Integration Tests | .Net Core WebApi | Fails seeds data when overriding a service in a test
C#CC# / help
10mo ago
Next page