public void StartSchedullerSuccessfully() { // Arrange var statusManager = new Mock <IStatusManager>(); var apiClient = new Mock <ISegmentSdkApiClient>(); var apiFetcher = new ApiSegmentChangeFetcher(apiClient.Object); var segments = new ConcurrentDictionary <string, Segment>(); var cache = new InMemorySegmentCache(segments); var segmentTaskQueue = new SegmentTaskQueue(); var segmentFetcher = new SelfRefreshingSegmentFetcher(apiFetcher, statusManager.Object, 10, cache, 1, segmentTaskQueue, new TasksManager(wrapperAdapter), wrapperAdapter); apiClient .Setup(x => x.FetchSegmentChanges(It.IsAny <string>(), It.IsAny <long>(), It.IsAny <FetchOptions>())) .Returns(Task.FromResult(PayedSplitJson)); // Act segmentFetcher.InitializeSegment("payed"); segmentFetcher.Start(); // Assert Assert.IsTrue(segmentTaskQueue.GetQueue().TryTake(out SelfRefreshingSegment segment, -1)); }
public void StartSchedullerSuccessfully() { //Arrange var gates = new Mock <IReadinessGatesCache>(); var apiClient = new Mock <ISegmentSdkApiClient>(); apiClient .Setup(x => x.FetchSegmentChanges(It.IsAny <string>(), It.IsAny <long>())) .Returns(Task.FromResult(@"{ 'name': 'payed', 'added': [ 'abcdz', 'bcadz', 'xzydz' ], 'removed': [], 'since': -1, 'till': 10001 }")); gates .Setup(mock => mock.IsSDKReady(0)) .Returns(true); var apiFetcher = new ApiSegmentChangeFetcher(apiClient.Object); var segments = new ConcurrentDictionary <string, Segment>(); var cache = new InMemorySegmentCache(segments); var segmentTaskQueue = new SegmentTaskQueue(); var segmentFetcher = new SelfRefreshingSegmentFetcher(apiFetcher, gates.Object, 10, cache, 1, segmentTaskQueue); //Act segmentFetcher.InitializeSegment("payed"); segmentFetcher.Start(); //Assert Assert.IsTrue(segmentTaskQueue.GetQueue().TryTake(out SelfRefreshingSegment segment, -1)); }