Exemplo n.º 1
0
        public void CircuitBreakerTripAndReset()
        {
            var circuitBreakerManager = new CircuitBreakerManager(circuitBreaker, sessionState);

            circuitBreakerManager.CircuitBreakerEnabled = true;
            circuitBreakerManager.ServiceEnabled        = false;
            var result = circuitBreakerManager.PerformAction();

            //see service failure message
            Assert.IsFalse(result.IsSuccess);
            Assert.AreEqual(CircuitBreakerManager.FailureMessage, result.Message);
            //try again to open circuit breaker
            result = circuitBreakerManager.PerformAction();
            Assert.IsFalse(result.IsSuccess);
            Assert.AreEqual(CircuitBreakerManager.FailureMessage, result.Message);
            //try again to see circuit breaker failure message
            result = circuitBreakerManager.PerformAction();
            Assert.IsFalse(result.IsSuccess);
            Assert.AreEqual(CircuitBreakerOpenException.ErrorMessage, result.Message);
            //wait 61 seconds for breaker to reset and set service to on and see success
            Thread.Sleep(61000);
            circuitBreakerManager.ServiceEnabled = true;
            result = circuitBreakerManager.PerformAction();
            Assert.IsTrue(result.IsSuccess);
        }
Exemplo n.º 2
0
        public void ServiceOffCircuitBreakerOff()
        {
            var circuitBreakerManager = new CircuitBreakerManager(circuitBreaker, sessionState);

            circuitBreakerManager.CircuitBreakerEnabled = false;
            circuitBreakerManager.ServiceEnabled        = false;
            var result = circuitBreakerManager.PerformAction();

            Assert.IsFalse(result.IsSuccess);
        }