private void Configure(CancellationBoundary testBoundary) { _commandHandler = new ManualCommandHandler(); _subscriber = new ManualSubscriber(); var resolver = EventFlowOptions.New() .AddCommands(typeof(ThingyPingCommand)) .AddEvents(typeof(ThingyPingEvent)) .UseInMemoryReadStoreFor <InMemoryThingyReadModel>() .Configure(c => c.CancellationBoundary = testBoundary) .RegisterServices(s => { s.Decorate <IInMemoryReadStore <InMemoryThingyReadModel>, ManualReadStore>(); s.Decorate <IEventPersistence, ManualEventPersistence>(); s.AddTransient <ICommandHandler <ThingyAggregate, ThingyId, IExecutionResult, ThingyPingCommand> >(c => _commandHandler); s.AddTransient <ISubscribeSynchronousTo <ThingyAggregate, ThingyId, ThingyPingEvent> >(c => _subscriber); s.AddTransient <IScopedContext, ScopedContext>(); }) .ServiceCollection.BuildServiceProvider(); _eventPersistence = (ManualEventPersistence)resolver.GetRequiredService <IEventPersistence>(); _readStore = (ManualReadStore)resolver.GetRequiredService <IInMemoryReadStore <InMemoryThingyReadModel> >(); _commandBus = resolver.GetRequiredService <ICommandBus>(); }
private void Configure(CancellationBoundary testBoundary) { _commandHandler = new ManualCommandHandler(); _subscriber = new ManualSubscriber(); _eventPersistence = null; _readStore = null; var resolver = EventFlowOptions .New .AddCommands(typeof(ThingyPingCommand)) .AddEvents(typeof(ThingyPingEvent)) .UseInMemoryReadStoreFor <InMemoryThingyReadModel>() .Configure(c => c.CancellationBoundary = testBoundary) .RegisterServices(s => { s.Decorate <IInMemoryReadStore <InMemoryThingyReadModel> >((c, i) => _readStore ?? (_readStore = new ManualReadStore(i))); s.Decorate <IEventPersistence>((c, i) => _eventPersistence ?? (_eventPersistence = new ManualEventPersistence(i))); s.Register <ICommandHandler <ThingyAggregate, ThingyId, IExecutionResult, ThingyPingCommand> >(c => _commandHandler); s.Register <ISubscribeSynchronousTo <ThingyAggregate, ThingyId, ThingyPingEvent> >(c => _subscriber); s.Register <IScopedContext, ScopedContext>(Lifetime.Scoped); }) .CreateResolver(); _commandBus = resolver.Resolve <ICommandBus>(); }