Example #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);
     }
 }
Example #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());
     }
 }
Example #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);
     }
 }
Example #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);
     }
 }
        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);
            }
        }
        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);
            }
        }
        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);
            }
        }