public GIVEN_read_model_rebuilder() { this.rebuildContext = this.readModelContextFactory.Invoke(); this.generatorEngine = new ReadModelGeneratorEngine <ItemReadModelDbContext>(rebuildContext, this.tracer); this.itemGenerator = new ItemReadModelGenerator(this.generatorEngine); this.eventDispatcher = new SynchronousEventDispatcher(this.tracer); this.eventDispatcher.Register(itemGenerator); this.sut = new ReadModelRebuilderEngine <ItemReadModelDbContext>(this.eventStoreContextFactory, this.serializer, this.eventDispatcher, rebuildContext, new Mock <IRebuilderPerfCounter>().Object); }
private IUnityContainer CreateContainer() { var container = new UnityContainer(); var config = this.domainRegistry.Config; container.RegisterInstance <IEventStoreRebuilderConfig>(config); container.RegisterInstance <ISystemTime>(config.SystemTime); var commandProcessor = new InMemoryCommandProcessor(this.tracer); var eventProcessor = new SynchronousEventDispatcher(this.tracer); container.RegisterInstance <ITextSerializer>(new JsonTextSerializer()); container.RegisterInstance <ITracer>(this.tracer); var snapshoter = new InMemorySnapshotProvider("Snapshotter", config.SystemTime); container.RegisterInstance <ISnapshotProvider>(snapshoter); container.RegisterInstance <IMetadataProvider>(new StandardMetadataProvider()); container.RegisterType <EventStoreDbContext>(new ContainerControlledLifetimeManager(), new InjectionConstructor(config.NewEventStoreConnectionString)); container.RegisterType(typeof(IEventStore <>), typeof(InMemoryEventStore <>), new ContainerControlledLifetimeManager()); container.RegisterInstance <IEventDispatcher>(eventProcessor); container.RegisterInstance <ICommandProcessor>(commandProcessor); container.RegisterInstance <ICommandHandlerRegistry>(commandProcessor); var bus = new InMemoryBus(); container.RegisterInstance <IInMemoryBus>(bus); var perfCounter = new EventStoreRebuilderPerfCounter(this.tracer, config.SystemTime); container.RegisterInstance <IRebuilderPerfCounter>(perfCounter); container.RegisterType(typeof(IEventStoreRebuilderEngine), typeof(EventStoreRebuilderEngine), new ContainerControlledLifetimeManager()); foreach (var registrationAction in this.domainRegistry.RegistrationList) { registrationAction(container, eventProcessor); } this.RegisterCommandHandlers(container); return(container); }
public void Rebuild() { var complexEventProcessor = new SynchronousEventDispatcher(this.tracer); var serializer = new JsonTextSerializer(); using (var context = domainRegistry.ContextFactory.Invoke()) { foreach (var registrationAction in domainRegistry.RegistrationList) { registrationAction(context, complexEventProcessor, this.tracer); } Func <EventStoreDbContext> eventStoreContextFactory = () => new EventStoreDbContext(domainRegistry.Config.EventStoreConnectionString); var perfCounter = new ReadModelRebuilderPerfCounter(this.tracer, this.domainRegistry.Config.SystemTime); var engine = new ReadModelRebuilderEngine <T>(eventStoreContextFactory, serializer, complexEventProcessor, context, perfCounter); engine.Rebuild(); this.PerformanceCounter = perfCounter; } }