public void GuardWillThrowWhenStateIsOpen()
 {
     // Fixture setup
     var fixture = new WcfFixture();
     fixture.Inject<TimeSpan>(1.Minutes());
     var sut = fixture.CreateAnonymous<CircuitBreaker>();
     sut.PutInOpenState();
     // Exercise system and verify outcome
     Assert.Throws<InvalidOperationException>(() =>
         sut.Guard());
     // Teardown
 }
Exemplo n.º 2
0
        public void GuardWillThrowWhenStateIsOpen()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            fixture.Inject <TimeSpan>(1.Minutes());
            var sut = fixture.CreateAnonymous <CircuitBreaker>();

            sut.PutInOpenState();
            // Exercise system and verify outcome
            Assert.Throws <InvalidOperationException>(() =>
                                                      sut.Guard());
            // Teardown
        }
Exemplo n.º 3
0
        public void GuardWillNotThrowWhenStateIsHalfOpen()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            fixture.Inject(1.Minutes());
            var sut = fixture.CreateAnonymous <CircuitBreaker>();

            sut.PutInHalfOpenState();
            // Exercise system
            sut.Guard();
            // Verify outcome (no exception indicates success)
            // Teardown
        }
Exemplo n.º 4
0
        public void SucceedWilTransitionToClosedWhenStateIsHalfOpen()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            fixture.Inject(1.Minutes());
            var sut = fixture.CreateAnonymous <CircuitBreaker>();

            sut.PutInHalfOpenState();
            // Exercise system
            sut.Succeed();
            // Verify outcome
            Assert.IsAssignableFrom <ClosedCircuitState>(sut.State);
            // Teardown
        }
Exemplo n.º 5
0
        public void TripWillTransitionToOpenWhenStateIsHalfOpen()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            fixture.Inject(1.Minutes());
            var sut = fixture.CreateAnonymous <CircuitBreaker>();

            sut.PutInHalfOpenState();
            // Exercise system
            fixture.Do((Exception e) => sut.Trip(e));
            // Verify outcome
            Assert.IsAssignableFrom <OpenCircuitState>(sut.State);
            // Teardown
        }
Exemplo n.º 6
0
        public void GuardWillTransitionToHalfOpenWhenStateIsOpenAndTimeoutIsReached()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            DateTime.Now.Freeze();

            fixture.Inject(1.Minutes());
            var sut = fixture.CreateAnonymous <CircuitBreaker>();

            sut.PutInOpenState();

            2.Minutes().Pass();
            // Exercise system
            sut.Guard();
            // Verify outcome
            Assert.IsAssignableFrom <HalfOpenCircuitState>(sut.State);
            // Teardown
        }
        public void GuardWillTransitionToHalfOpenWhenStateIsOpenAndTimeoutIsReached()
        {
            // Fixture setup
            var fixture = new WcfFixture();

            DateTime.Now.Freeze();

            fixture.Inject(1.Minutes());
            var sut = fixture.CreateAnonymous<CircuitBreaker>();
            sut.PutInOpenState();

            2.Minutes().Pass();
            // Exercise system
            sut.Guard();
            // Verify outcome
            Assert.IsAssignableFrom<HalfOpenCircuitState>(sut.State);
            // Teardown
        }
 public void SucceedWilTransitionToClosedWhenStateIsHalfOpen()
 {
     // Fixture setup
     var fixture = new WcfFixture();
     fixture.Inject(1.Minutes());
     var sut = fixture.CreateAnonymous<CircuitBreaker>();
     sut.PutInHalfOpenState();
     // Exercise system
     sut.Succeed();
     // Verify outcome
     Assert.IsAssignableFrom<ClosedCircuitState>(sut.State);
     // Teardown
 }
 public void GuardWillNotThrowWhenStateIsHalfOpen()
 {
     // Fixture setup
     var fixture = new WcfFixture();
     fixture.Inject(1.Minutes());
     var sut = fixture.CreateAnonymous<CircuitBreaker>();
     sut.PutInHalfOpenState();
     // Exercise system
     sut.Guard();
     // Verify outcome (no exception indicates success)
     // Teardown
 }
Exemplo n.º 10
0
 public void TripWillTransitionToOpenWhenStateIsHalfOpen()
 {
     // Fixture setup
     var fixture = new WcfFixture();
     fixture.Inject(1.Minutes());
     var sut = fixture.CreateAnonymous<CircuitBreaker>();
     sut.PutInHalfOpenState();
     // Exercise system
     fixture.Do((Exception e) => sut.Trip(e));
     // Verify outcome
     Assert.IsAssignableFrom<OpenCircuitState>(sut.State);
     // Teardown
 }