コード例 #1
0
 public void SuccessfulRequestSetsInitializedToTrue()
 {
     _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ReturnsAsync(MakeAllData());
     using (PollingProcessor pp = MakeProcessor())
     {
         var initTask = pp.Start();
         initTask.Wait();
         Assert.True(pp.Initialized);
         Assert.Equal(DataSourceState.Valid, _dataSourceStatusProvider.Status.State);
     }
 }
コード例 #2
0
 public void SuccessfulRequestPutsFeatureDataInStore()
 {
     _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ReturnsAsync(MakeAllData());
     using (PollingProcessor pp = MakeProcessor())
     {
         var initTask = pp.Start();
         initTask.Wait();
         Assert.Equal(Flag, _dataStore.Get(DataModel.Features, Flag.Key).Value.Item);
         Assert.Equal(Segment, _dataStore.Get(DataModel.Segments, Segment.Key).Value.Item);
         Assert.True(_dataStore.Initialized());
     }
 }
コード例 #3
0
 private void VerifyRecoverableHttpError(int status)
 {
     _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync(
         new UnsuccessfulResponseException(status));
     using (PollingProcessor pp = MakeProcessor())
     {
         var  initTask  = pp.Start();
         bool completed = initTask.Wait(TimeSpan.FromMilliseconds(200));
         Assert.False(completed);
         Assert.False(pp.Initialized);
     }
 }
コード例 #4
0
 public void ConnectionErrorDoesNotCauseImmediateFailure()
 {
     _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync(new InvalidOperationException("no"));
     using (PollingProcessor pp = MakeProcessor())
     {
         var  startTime = DateTime.Now;
         var  initTask  = pp.Start();
         bool completed = initTask.Wait(TimeSpan.FromMilliseconds(200));
         Assert.InRange(DateTime.Now.Subtract(startTime).Milliseconds, 190, 2000);
         Assert.False(completed);
         Assert.False(pp.Initialized);
         Assert.Equal(DataSourceState.Initializing, _dataSourceStatusProvider.Status.State);
     }
 }
コード例 #5
0
        public void ConnectionErrorDoesNotCauseImmediateFailure()
        {
            _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync(new InvalidOperationException("no"));

            using (PollingProcessor pp = MakeProcessor())
            {
                var  initTask  = pp.Start();
                bool completed = initTask.Wait(TimeSpan.FromMilliseconds(200));
                Assert.False(completed);
                Assert.False(pp.Initialized);

                var receivedStatus = _updates.StatusUpdates.ExpectValue();
                Assert.Equal(DataSourceState.Interrupted, receivedStatus.State);
            }
        }
コード例 #6
0
        public void SuccessfulRequestPutsFeatureDataInStore()
        {
            var expectedData = MakeAllData();

            _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ReturnsAsync(expectedData);

            using (PollingProcessor pp = MakeProcessor())
            {
                var initTask = pp.Start();
                initTask.Wait();

                var receivedData = _updates.Inits.ExpectValue();
                AssertHelpers.DataSetsEqual(expectedData, receivedData);
            }
        }
コード例 #7
0
        public void VerifyUnrecoverableHttpError(int status)
        {
            _mockFeatureRequestor.Setup(fr => fr.GetAllDataAsync()).ThrowsAsync(
                new UnsuccessfulResponseException(status));

            using (PollingProcessor pp = MakeProcessor())
            {
                var  initTask  = pp.Start();
                bool completed = initTask.Wait(TimeSpan.FromMilliseconds(1000));
                Assert.True(completed);
                Assert.False(pp.Initialized);

                var receivedStatus = _updates.StatusUpdates.ExpectValue();
                Assert.Equal(DataSourceState.Off, receivedStatus.State);
                Assert.NotNull(receivedStatus.Error);
                Assert.Equal(status, receivedStatus.Error.Value.StatusCode);
            }
        }