Amazon.KinesisTap.Core.Test/DependencyEventSourceTest.cs
/// <summary>
/// Tests the case where a dependency temporarily becomes unavailable while the source is running.
/// </summary>
Tests the case where a dependency temporarily becomes unavailable while the source is running.
Tests the case where a dependency temporarily becomes unavailable while the source is running .
[Fact]
        public void TestRunningWithUnavailableDependency()
        {
            var eventSource = GetMockDependentEventSource();
            eventSource.DelayBetweenDependencyPoll = TimeSpan.FromMilliseconds(500);
            eventSource.IsAvailable = true;
            eventSource.Start();
            Assert.Equal(MockSourceStates.Started, eventSource.State);
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.Equal(MockSourceStates.Started, eventSource.State);
            eventSource.IsAvailable = false;
            eventSource.Reset();
            Assert.Equal(MockSourceStates.Stopped, eventSource.State);
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.Equal(MockSourceStates.Stopped, eventSource.State);
            eventSource.IsAvailable = true;
            Thread.Sleep(TimeSpan.FromSeconds(2));
            Assert.Equal(MockSourceStates.Started, eventSource.State);
            Thread.Sleep(TimeSpan.FromSeconds(1));
            Assert.Equal(MockSourceStates.Started, eventSource.State);
        }
[ Fact ] public void TestRunningWithUnavailableDependency ( ) { var eventSource = GetMockDependentEventSource ( ) ; eventSource . DelayBetweenDependencyPoll = TimeSpan . FromMilliseconds ( 500 ) ; eventSource . IsAvailable = true ; eventSource . Start ( ) ; Assert . Equal ( MockSourceStates . Started , eventSource . State ) ; Thread . Sleep ( TimeSpan . FromSeconds ( 1 ) ) ; Assert . Equal ( MockSourceStates . Started , eventSource . State ) ; eventSource . IsAvailable = false ; eventSource . Reset ( ) ; Assert . Equal ( MockSourceStates . Stopped , eventSource . State ) ; Thread . Sleep ( TimeSpan . FromSeconds ( 1 ) ) ; Assert . Equal ( MockSourceStates . Stopped , eventSource . State ) ; eventSource . IsAvailable = true ; Thread . Sleep ( TimeSpan . FromSeconds ( 2 ) ) ; Assert . Equal ( MockSourceStates . Started , eventSource . State ) ; Thread . Sleep ( TimeSpan . FromSeconds ( 1 ) ) ; Assert . Equal ( MockSourceStates . Started , eventSource . State ) ; }
Tests the case where a dependency temporarily becomes unavailable while the source is running.
Tests the case where a dependency temporarily becomes unavailable while the source is running .
//Setup //Execute //Verify //Simulate detecting a problem during use of source //Simulate recovery