From 80f56145798911f2ea416bd862620c54a99f0eba Mon Sep 17 00:00:00 2001 From: Jean Gatto Date: Sun, 10 Aug 2025 09:04:11 -0300 Subject: [PATCH] refactor(tests): streamline service removal in CustomersControllerTests --- src/Shop.Application/ConfigureServices.cs | 3 ++- .../V1/CustomersControllerTests.cs | 25 +++++++++---------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Shop.Application/ConfigureServices.cs b/src/Shop.Application/ConfigureServices.cs index 7c07c96..9a54a09 100644 --- a/src/Shop.Application/ConfigureServices.cs +++ b/src/Shop.Application/ConfigureServices.cs @@ -20,7 +20,8 @@ public static class ConfigureServices var assembly = Assembly.GetAssembly(typeof(IApplicationMarker)); return services .AddValidatorsFromAssembly(assembly, ServiceLifetime.Singleton) - .AddMediatR(cfg => cfg.RegisterServicesFromAssembly(assembly) + .AddMediatR(cfg => cfg + .RegisterServicesFromAssembly(assembly) .AddBehavior(typeof(IPipelineBehavior<,>), typeof(LoggingBehavior<,>))); } } \ No newline at end of file diff --git a/tests/Shop.IntegrationTests/Controllers/V1/CustomersControllerTests.cs b/tests/Shop.IntegrationTests/Controllers/V1/CustomersControllerTests.cs index 1c9fd52..27f8890 100644 --- a/tests/Shop.IntegrationTests/Controllers/V1/CustomersControllerTests.cs +++ b/tests/Shop.IntegrationTests/Controllers/V1/CustomersControllerTests.cs @@ -484,14 +484,15 @@ public class CustomersControllerTests : IAsyncLifetime hostBuilder.ConfigureServices(services => { - services.RemoveAll(); - services.RemoveAll(); - services.RemoveAll(); - services.RemoveAll>(); - services.RemoveAll(); - services.RemoveAll>(); - services.RemoveAll(); - services.RemoveAll(); + services + .RemoveAll() + .RemoveAll() + .RemoveAll() + .RemoveAll>() + .RemoveAll() + .RemoveAll>() + .RemoveAll() + .RemoveAll(); services.AddDbContext( options => options @@ -503,8 +504,9 @@ public class CustomersControllerTests : IAsyncLifetime .UseSqlite(_eventStoreDbContextSqlite) .ConfigureWarnings(warningBuilder => warningBuilder.Ignore(InMemoryEventId.TransactionIgnoredWarning))); - services.AddSingleton(_ => Substitute.For()); - services.AddSingleton(_ => Substitute.For()); + services + .AddSingleton(_ => Substitute.For()) + .AddSingleton(_ => Substitute.For()); configureServices?.Invoke(services); @@ -518,9 +520,6 @@ public class CustomersControllerTests : IAsyncLifetime eventStoreDbContext.Database.EnsureCreated(); configureServiceScope?.Invoke(serviceScope); - - writeDbContext.Dispose(); - eventStoreDbContext.Dispose(); }); }); }