public void AddToQueue_WithElements_ShouldTriggerFetch() { // Arrange. _splitsWorker.Start(); _splitCache .SetupSequence(mock => mock.GetChangeNumber()) .Returns(1585956698447) .Returns(1585956698457) .Returns(1585956698467) .Returns(1585956698477); // Act. _splitsWorker.AddToQueue(1585956698457); _splitsWorker.AddToQueue(1585956698467); _splitsWorker.AddToQueue(1585956698477); Thread.Sleep(50); _splitsWorker.AddToQueue(1585956698476); Thread.Sleep(1000); _splitsWorker.Stop(); _splitsWorker.AddToQueue(1585956698486); Thread.Sleep(100); _splitsWorker.AddToQueue(1585956698496); Thread.Sleep(100); // Assert. _splitCache.Verify(mock => mock.GetChangeNumber(), Times.Exactly(4)); _synchronizer.Verify(mock => mock.SynchronizeSplits(), Times.Exactly(3)); }
public void AddToQueue_WithElements_ShouldTriggerFetch() { // Act. _splitsWorker.Start(); _splitsWorker.AddToQueue(1585956698457); _splitsWorker.AddToQueue(1585956698467); _splitsWorker.AddToQueue(1585956698477); _splitsWorker.AddToQueue(1585956698476); Thread.Sleep(1000); _splitsWorker.Stop(); _splitsWorker.AddToQueue(1585956698486); Thread.Sleep(100); _splitsWorker.AddToQueue(1585956698496); // Assert _synchronizer.Verify(mock => mock.SynchronizeSplits(It.IsAny <long>()), Times.Exactly(4)); }
public void StopWorkers() { _splitsWorker.Stop(); _segmentsWorker.Stop(); }