using FinancialApi.Application.Handlers; using FinancialApi.Application.Interfaces; using FinancialApi.Domain.Events; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Time.Testing; using Wolverine; namespace FinancialApi.Infrastructure.Tests; public class WolverineTestFixture : IDisposable { public IHost Host { get; } public WolverineTestFixture() { // We build and start the host ONCE here Host = Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder() .ConfigureServices((context, services) => { services.AddSingleton(_ => new FakeAccountQuery()); services.AddSingleton(_ => new FakeTimeProvider()); services.AddSingleton(_ => new DemoEventStore()); } ) .UseWolverine(opts => { opts.Discovery.IncludeAssembly(typeof(ApplyFeeHandler).Assembly); }) .Start(); } public void Dispose() { Host.Dispose(); } }