public async Task StartsMessageProcessing()
        {
            var subscriptionProcessor = new Mock <ISubscriptionProcessor <PackageValidationMessageData> >();
            var loggerMock            = new Mock <ILogger <OrchestrationRunner> >();
            var optionsAccessorMock   = CreateOptionsAccessorMock(TimeSpan.Zero, TimeSpan.Zero);

            var runner = new OrchestrationRunner(subscriptionProcessor.Object, optionsAccessorMock.Object, loggerMock.Object);
            await runner.RunOrchestrationAsync();

            subscriptionProcessor.Verify(o => o.Start(), Times.Once());
        }
        public async Task WaitsOrchestratorToShutDown()
        {
            var orchestratorMock    = new Mock <ISubscriptionProcessor <PackageValidationMessageData> >();
            var loggerMock          = new Mock <ILogger <OrchestrationRunner> >();
            var optionsAccessorMock = CreateOptionsAccessorMock(TimeSpan.Zero, TimeSpan.FromSeconds(2));

            int numberOfRequestsInProgress = 2;

            orchestratorMock
            .SetupGet(o => o.NumberOfMessagesInProgress)
            .Returns(() => numberOfRequestsInProgress--);

            var runner = new OrchestrationRunner(orchestratorMock.Object, optionsAccessorMock.Object, loggerMock.Object);
            await runner.RunOrchestrationAsync();

            orchestratorMock.Verify(o => o.NumberOfMessagesInProgress, Times.Exactly(3));
        }
        public async Task ShutsDownMessageProcessing()
        {
            var orchestratorMock    = new Mock <ISubscriptionProcessor <PackageValidationMessageData> >();
            var loggerMock          = new Mock <ILogger <OrchestrationRunner> >();
            var optionsAccessorMock = CreateOptionsAccessorMock(TimeSpan.Zero, TimeSpan.Zero);

            var startCalled = false;

            orchestratorMock
            .Setup(o => o.Start())
            .Callback(() => startCalled = true);

            orchestratorMock
            .Setup(o => o.StartShutdownAsync())
            .Callback(() => Assert.True(startCalled))
            .Returns(Task.FromResult(0));
            var runner = new OrchestrationRunner(orchestratorMock.Object, optionsAccessorMock.Object, loggerMock.Object);
            await runner.RunOrchestrationAsync();

            orchestratorMock.Verify(o => o.StartShutdownAsync(), Times.Once());
        }