public async Task HandleAsync_RunsSuccessfully()
        {
            ProcessAsyncEventsJob job = new ProcessAsyncEventsJob("queue", 5, TimeSpan.FromMinutes(1));
            await sut.HandleAsync(job, CancellationToken.None);

            asyncEventWorker.Received(1).RunQueueBacklogAsync(job.QueueName);
        }
        public async Task HandleAsync_NoRetriesLeftForOptimisticConcurrencyException()
        {
            ProcessAsyncEventsJob job = new ProcessAsyncEventsJob("queue", 1, TimeSpan.FromMinutes(1));

            asyncEventWorker.When(x => x.RunQueueBacklogAsync(job.QueueName)).Throw(new OptimisticConcurrencyException());

            await sut.HandleAsync(job, CancellationToken.None);

            jobScheduler.DidNotReceiveWithAnyArgs().EnqeueJobAsync(null, null);
        }
        public async Task HandleAsync_RetryOptimisticConcurrencyException()
        {
            ProcessAsyncEventsJob job = new ProcessAsyncEventsJob("queue", 5, TimeSpan.FromMinutes(1));

            asyncEventWorker.When(x => x.RunQueueBacklogAsync(job.QueueName)).Throw(new OptimisticConcurrencyException());

            await sut.HandleAsync(job, CancellationToken.None);

            jobScheduler.Received(1).EnqeueJobAsync(Arg.Is <ProcessAsyncEventsJob>(x => x.AttemptsLeft == 4 &&
                                                                                   x.RetryTimeout == TimeSpan.FromTicks(job.RetryTimeout.Ticks * asyncEventPipelineConfiguration.AsyncProcessRetryTimeoutMultiplier) &&
                                                                                   x.QueueName == "queue"), job.RetryTimeout);
        }