using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace MeetingAssistant.Tests; public sealed class IsolatedApplicationFactory : WebApplicationFactory { protected override void ConfigureWebHost(IWebHostBuilder builder) { builder.ConfigureTestServices(services => { // Endpoint tests retain production composition but opt into each background activity they exercise. foreach (var descriptor in services.Where(descriptor => descriptor.ServiceType == typeof(IHostedService) && (descriptor.ImplementationType?.Assembly == typeof(Program).Assembly || descriptor.ImplementationFactory is not null)).ToArray()) { services.Remove(descriptor); } }); } }