private async Task SetupWithMock(SynchronizerMockBehavior mockBehavior)
        {
            var synchronizer = MockRepository.GenerateStrictMock <IOutlookSynchronizer>();

            await SetupSynchronizerFactory(synchronizer);

            _dateTimeProvider.Now = new DateTime(2000, 1, 1);

            synchronizer
            .Expect(_ => synchronizer.Synchronize(Arg <ISynchronizationLogger> .Is.NotNull))
            .Return(Task.FromResult(0))
            .WhenCalled(_ =>
            {
                if (mockBehavior.ThrowOverloadException)
                {
                    throw new WebRepositoryOverloadException(null, new Exception());
                }
            });
        }
        public async Task RunAndRescheduleNoThrow_SynchronizerThrowsOverloadException_ReportsErrorWhenTriggeredManually()
        {
            var synchronizerBehavior = new SynchronizerMockBehavior();

            await SetupWithMock(synchronizerBehavior);

            synchronizerBehavior.ThrowOverloadException = true;
            await Synchronize(false);
            await Synchronize(true);

            CollectionAssert.AreEqual(
                new[]
            {
                new { HasWarnings = true, HasErrors = false },
                new { HasWarnings = false, HasErrors = true }
            },
                _synchronizationReportSink.Reports.Select(r => new { r.HasWarnings, r.HasErrors }));


            _synchronizationReportSink.Reports.Clear();
            await Synchronize(false);
            await Synchronize(true);
            await Synchronize(false);
            await Synchronize(false);
            await Synchronize(false);
            await Synchronize(true);
            await Synchronize(false);

            CollectionAssert.AreEqual(
                new[]
            {
                new { HasWarnings = true, HasErrors = false },
                new { HasWarnings = false, HasErrors = true },
                new { HasWarnings = true, HasErrors = false },
                new { HasWarnings = true, HasErrors = false },
                new { HasWarnings = false, HasErrors = true },
                new { HasWarnings = false, HasErrors = true },
                new { HasWarnings = true, HasErrors = false },
            },
                _synchronizationReportSink.Reports.Select(r => new { r.HasWarnings, r.HasErrors }));
        }