Beispiel #1
0
        public async Task SubscriptionWorker_CanBeStartedAndStopped()
        {
            CancellationToken  cancellationToken = CancellationToken.None;
            SubscriptionWorker sw = SubscriptionWorker.CreateConcurrentSubscriptionWorker(this.EventStoreConnectionString,
                                                                                          this.domainEventHandlerResolver.Object,
                                                                                          this.SubscriptionRepository).UseInMemory();

            await sw.StartAsync(cancellationToken);

            //Give our service time to run
            await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken);

            sw.IsRunning.ShouldBeTrue();

            await sw.StopAsync(cancellationToken);

            sw.IsRunning.ShouldBe(false);

            var stillConnected = sw.GetPersistentSubscription().Count;

            stillConnected.ShouldBe(0);
        }