public void DelaysNextSyncEventUntilQueueEmpty() { var queue = new Mock<ISyncEventQueue>(); var underTest = new DelayRetryAndNextSyncEventHandler(queue.Object); queue.Setup(q => q.IsEmpty).Returns(false); Assert.True(underTest.Handle(new StartNextSyncEvent())); queue.Setup(q => q.IsEmpty).Returns(true); Assert.False(underTest.Handle(Mock.Of<ISyncEvent>())); queue.Verify(q => q.AddEvent(It.Is<StartNextSyncEvent>(e => e.FullSyncRequested == false))); }
public void FullSyncFlagIsStored() { var queue = new Mock<ISyncEventQueue>(); var underTest = new DelayRetryAndNextSyncEventHandler(queue.Object); queue.Setup(q => q.IsEmpty).Returns(false); Assert.True(underTest.Handle(new StartNextSyncEvent(true))); queue.Setup(q => q.IsEmpty).Returns(true); Assert.True(underTest.Handle(new StartNextSyncEvent(false))); queue.Verify(q => q.AddEvent(It.Is<StartNextSyncEvent>(e => e.FullSyncRequested == true)), Times.Once()); }
public void DoNotDelayStartSyncWhenQueueEmpty() { var queue = new Mock<ISyncEventQueue>(); queue.Setup(q => q.IsEmpty).Returns(true); var underTest = new DelayRetryAndNextSyncEventHandler(queue.Object); Assert.False(underTest.Handle(new StartNextSyncEvent())); }
public void RetryEventsAreSavedAndReinsertedAfterNonFullSyncRequested() { var queue = new Mock<ISyncEventQueue>(); var underTest = new DelayRetryAndNextSyncEventHandler(queue.Object); queue.Setup(q => q.IsEmpty).Returns(true); var syncEvent1 = new FileEvent(Mock.Of<IFileInfo>()) { RetryCount = 1 }; var syncEvent2 = new FileEvent(Mock.Of<IFileInfo>()) { RetryCount = 1 }; Assert.True(underTest.Handle(syncEvent1)); Assert.True(underTest.Handle(syncEvent2)); queue.Verify(q => q.AddEvent(syncEvent1), Times.Never()); queue.Verify(q => q.AddEvent(syncEvent2), Times.Never()); Assert.True(underTest.Handle(new StartNextSyncEvent(false))); queue.Verify(q => q.AddEvent(syncEvent1), Times.Once()); queue.Verify(q => q.AddEvent(syncEvent2), Times.Once()); }
public void DoesNotHandleNonRetryEvent() { var underTest = new DelayRetryAndNextSyncEventHandler(Mock.Of<ISyncEventQueue>()); var fileEvent = new FileEvent(Mock.Of<IFileInfo>()) { RetryCount = 0 }; Assert.False(underTest.Handle(fileEvent)); }