public async Task Circuit_Opened_On_Timeout()
        {
            CircuitBreaker <string, string> circuitBreaker = new CircuitBreaker <string, string>(async req =>
            {
                await Task.Delay(2000);
                return(await Task.FromResult("test"));
            }, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2));

            await Assert.ThrowsExceptionAsync <TimeoutException>(() => circuitBreaker.Call("test"));

            Assert.AreEqual(circuitBreaker.State, CircuitBreakerState.Open);
        }
        public async Task Circuit_Closed_After_Opend_And_HalfOpen_After_Succed()
        {
            bool @throw = true;

            CircuitBreaker <string, string> circuitBreaker = new CircuitBreaker <string, string>(req =>
            {
                if (@throw)
                {
                    @throw = !@throw;
                    throw new Exception();
                }

                return(Task.FromResult("ssucced"));
            }, TimeSpan.FromSeconds(3), TimeSpan.FromSeconds(2));

            await Assert.ThrowsExceptionAsync <Exception>(() => circuitBreaker.Call("test"));

            await Task.Delay(2500);

            await circuitBreaker.Call("test");

            Assert.AreEqual(circuitBreaker.State, CircuitBreakerState.Closed);
        }