public async Task Setup() { await MigrateUp(); InterceptQuartzSystemTime(); var collection = new ServiceCollection() .AddSingleton <ILoggerFactory>(provider => new TestOutputLoggerFactory(true)) .AddDbContext <IntegrationTestDbContext>(x => { IntegrationTestSagaDbContextFactory.Apply(x); }) .AddMassTransitInMemoryTestHarness(cfg => { cfg.AddSagaStateMachine <TStateMachine, TInstance>() .EntityFrameworkRepository(x => { x.LockStatementProvider = new PostgresLockStatementProvider(); x.ExistingDbContext <IntegrationTestDbContext>(); }); cfg.AddPublishMessageScheduler(); cfg.AddSagaStateMachineTestHarness <TStateMachine, TInstance>(); ConfigureMassTransit(cfg); }); ConfigureServices(collection); Provider = collection.BuildServiceProvider(true); ConfigureLogging(); TestHarness = Provider.GetRequiredService <InMemoryTestHarness>(); TestHarness.OnConfigureInMemoryBus += configurator => { configurator.UseInMemoryScheduler(out _scheduler); }; await TestHarness.Start(); SagaHarness = Provider.GetRequiredService <IStateMachineSagaTestHarness <TInstance, TStateMachine> >(); Machine = Provider.GetRequiredService <TStateMachine>(); }
static async Task MigrateDown() { await using var context = new IntegrationTestSagaDbContextFactory().CreateDbContext(); await context.Database.EnsureDeletedAsync(); }
static async Task MigrateUp() { await using var context = new IntegrationTestSagaDbContextFactory().CreateDbContext(); await context.Database.MigrateAsync(); }