public void AddToQueue_WithElements_ShouldTriggerFetch() { // Arrange. var changeNumber = 1585956698457; var segmentName = "segment-test"; var changeNumber2 = 1585956698467; var segmentName2 = "segment-test-2"; var changeNumber3 = 1585956698477; var segmentName3 = "segment-test-3"; _segmentsWorker.Start(); // Act. _segmentsWorker.AddToQueue(changeNumber, segmentName); _segmentsWorker.AddToQueue(changeNumber2, segmentName2); _segmentsWorker.AddToQueue(changeNumber3, segmentName3); Thread.Sleep(1000); _segmentsWorker.Stop(); _segmentsWorker.AddToQueue(1585956698487, "segment-test-4"); Thread.Sleep(10); // Assert. _synchronizer.Verify(mock => mock.SynchronizeSegment(It.IsAny <string>(), It.IsAny <long>()), Times.Exactly(3)); }
public void Proccess(IncomingNotification notification) { try { switch (notification.Type) { case NotificationType.SPLIT_UPDATE: var scn = (SplitChangeNotifiaction)notification; _splitsWorker.AddToQueue(scn.ChangeNumber); break; case NotificationType.SPLIT_KILL: var skn = (SplitKillNotification)notification; _splitsWorker.KillSplit(skn.ChangeNumber, skn.SplitName, skn.DefaultTreatment); _splitsWorker.AddToQueue(skn.ChangeNumber); break; case NotificationType.SEGMENT_UPDATE: var sc = (SegmentChangeNotification)notification; _segmentsWorker.AddToQueue(sc.ChangeNumber, sc.SegmentName); break; default: _log.Debug($"Incorrect Event type: {notification}"); break; } } catch (Exception ex) { _log.Error($"Processor: {ex.Message}"); } }