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 }
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 }
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 }
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 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 }
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 }
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 }