예제 #1
0
 private static async Task InitializeEventStoreAsync(IWebHost host)
 {
     using (var scope = host.Services.CreateScope())
     {
         var services          = scope.ServiceProvider;
         var projectionManager = services.GetRequiredService <ProjectionsManager>();
         var options           = services.GetRequiredService <IOptions <AppSettings> >();
         var credentials       = new UserCredentials(options.Value.EVENTSTORE_USERNAME, options.Value.EVENTSTORE_PASSWORD);
         await EventStoreInitializer.InitializeAsync(projectionManager, credentials);
     }
 }
        public void EventStoreInitializerShouldThrowExceptionWhenReplayCalledTwice()
        {
            var eventBus       = new Mock <IEventBus>();
            var loggingService = new Mock <ILoggingService>();
            var performance    = new Mock <IPerformanceMeasurementService>();

            var eventStore = new Mock <IEventStore>();

            eventStore.Setup(s => s.GetEvents()).Returns(Enumerable.Empty <IDomainEvent>());

            var initializer = new EventStoreInitializer(eventStore.Object, eventBus.Object, loggingService.Object, performance.Object);

            initializer.Replay();

            Action action = () => initializer.Replay();

            action.Should().Throw <EventStoreInitializeException>();
        }