Example #1
0
            public async Task DoesNotUpdateCursorIfIncidentCollectorFails()
            {
                ManualStatusChangeCollector1
                .Setup(x => x.FetchLatest())
                .ReturnsAsync(new DateTime(2018, 11, 12))
                .Verifiable();

                ManualStatusChangeCollector2
                .Setup(x => x.FetchLatest())
                .ReturnsAsync(new DateTime(2018, 11, 13))
                .Verifiable();

                IncidentCollector
                .Setup(x => x.FetchLatest())
                .ThrowsAsync(new Exception())
                .Verifiable();

                var cursor = new DateTime(2018, 11, 12);
                await Updater.Update(cursor);

                ManualStatusChangeCollector1.Verify();
                ManualStatusChangeCollector2.Verify();
                IncidentCollector.Verify();

                ActiveEventEntityUpdater
                .Verify(
                    x => x.UpdateAllAsync(It.IsAny <DateTime>()),
                    Times.Never());

                Cursor
                .Verify(
                    x => x.Set(It.IsAny <string>(), It.IsAny <DateTime>()),
                    Times.Never());
            }
Example #2
0
            public async Task UpdatesCursorIfSuccessful()
            {
                ManualStatusChangeCollector1
                .Setup(x => x.FetchLatest())
                .ReturnsAsync(new DateTime(2018, 11, 12))
                .Verifiable();

                ManualStatusChangeCollector2
                .Setup(x => x.FetchLatest())
                .ReturnsAsync(new DateTime(2018, 11, 13))
                .Verifiable();

                IncidentCollector
                .Setup(x => x.FetchLatest())
                .ReturnsAsync(new DateTime(2018, 11, 14))
                .Verifiable();

                var cursor = new DateTime(2018, 11, 12);

                ActiveEventEntityUpdater
                .Setup(x => x.UpdateAllAsync(cursor))
                .Returns(Task.CompletedTask)
                .Verifiable();

                Cursor
                .Setup(x => x.Set(StatusUpdater.LastUpdatedCursorName, cursor))
                .Returns(Task.CompletedTask)
                .Verifiable();

                await Updater.Update(cursor);

                ManualStatusChangeCollector1.Verify();
                ManualStatusChangeCollector2.Verify();
                IncidentCollector.Verify();
                ActiveEventEntityUpdater.Verify();
                Cursor.Verify();
            }