public void SuccessfulRequestSetsInitializedToTrue() { AllData allData = MakeAllData(); _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ReturnsAsync(allData); using (PollingProcessor pp = new PollingProcessor(_config, _featureRequestor, _featureStore)) { var initTask = ((IUpdateProcessor)pp).Start(); initTask.Wait(); Assert.True(((IUpdateProcessor)pp).Initialized()); } }
private void VerifyRecoverableHttpError(int status) { _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync( new UnsuccessfulResponseException(status)); using (PollingProcessor pp = new PollingProcessor(_config, _featureRequestor, _featureStore)) { var initTask = ((IUpdateProcessor)pp).Start(); bool completed = initTask.Wait(TimeSpan.FromMilliseconds(200)); Assert.False(completed); Assert.False(((IUpdateProcessor)pp).Initialized()); } }
public void ConnectionErrorDoesNotCauseImmediateFailure() { _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync(new InvalidOperationException("no")); using (PollingProcessor pp = new PollingProcessor(_config, _featureRequestor, _featureStore)) { var startTime = DateTime.Now; var initTask = ((IUpdateProcessor)pp).Start(); bool completed = initTask.Wait(TimeSpan.FromMilliseconds(200)); Assert.InRange(DateTime.Now.Subtract(startTime).Milliseconds, 190, 2000); Assert.False(completed); Assert.False(((IUpdateProcessor)pp).Initialized()); } }
public void SuccessfulRequestPutsFeatureDataInStore() { AllData allData = MakeAllData(); _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ReturnsAsync(allData); using (PollingProcessor pp = new PollingProcessor(_config, _featureRequestor, _featureStore)) { var initTask = ((IUpdateProcessor)pp).Start(); initTask.Wait(); Assert.Equal(Flag, _featureStore.Get(VersionedDataKind.Features, Flag.Key)); Assert.Equal(Segment, _featureStore.Get(VersionedDataKind.Segments, Segment.Key)); Assert.True(_featureStore.Initialized()); } }
public ChatTools(EliteAPI api) { _api = api; _timer = new PollingProcessor(QueueChatEntries); _timer.Start(); }