Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public void StartWorkers()
 {
     _splitsWorker.Start();
     _segmentsWorker.Start();
 }