Files
meeting-assistant/MeetingAssistant.Tests/IsolatedApplicationFactory.cs
T
dh 728e66dd72
PR and Push Build/Test / windows-build-and-test (push) Failing after 38m25s
PR and Push Build/Test / portable-build-and-test (push) Successful in 8m9s
PR and Push Build/Test / macos-native-full (push) Skipped
ci: consolidate platform pipelines and test prerequisites on macOS support
2026-10-06 09:02:19 +02:00

26 lines
956 B
C#

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<Program>
{
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);
}
});
}
}