public void SynchronizeSegment_ShouldFetchSegmentByName() { // Arrange. var segmentName = "segment-test"; _segmentCache .SetupSequence(mock => mock.GetChangeNumber(segmentName)) .Returns(-1) .Returns(2); // Act. _synchronizer.SynchronizeSegment(segmentName, 1); // Assert. _segmentFetcher.Verify(mock => mock.Fetch(segmentName, It.IsAny <FetchOptions>()), Times.Once); }
public void SynchronizeSegment_ShouldFetchSegmentByName() { // Arrange. var segmentName = "segment-test"; // Act. _synchronizer.SynchronizeSegment(segmentName); // Assert. _segmentFetcher.Verify(mock => mock.Fetch(segmentName), Times.Once); }
public async void Execute() { try { while (!_cancellationTokenSource.IsCancellationRequested) { //Wait indefinitely until a segment is queued if (_queue.TryTake(out SegmentQueueDto segment, -1)) { _log.Debug($"Segment dequeue: {segment.SegmentName}"); if (segment.ChangeNumber > _segmentCache.GetChangeNumber(segment.SegmentName)) { await _synchronizer.SynchronizeSegment(segment.SegmentName); } } } } catch (Exception ex) { _log.Error($"Execute: {ex.Message}"); } }
public async void Execute() { try { _log.Debug($"Segments Worker, Token: {_cancellationTokenSource.IsCancellationRequested}; Running: {_running}."); while (!_cancellationTokenSource.IsCancellationRequested && _running) { // Wait indefinitely until a segment is queued if (_queue.TryTake(out SegmentQueueDto segment, -1, _cancellationTokenSource.Token)) { _log.Debug($"Segment dequeue: {segment.SegmentName}"); await _synchronizer.SynchronizeSegment(segment.SegmentName, segment.ChangeNumber); } } } catch (Exception ex) { _log.Error($"Execute: {ex.Message}"); } finally { _log.Debug("Segment Worker execution finished."); } }