예제 #1
0
        public void VerifyNewBreakersInheritExistingState()
        {
            var aThread = new Thread(DoThreadWork); // trip a breaker in a new thread
            var randoBreaker = new Breaker(typeof(SomeRandomClass)); // setup a new breaker, for a breaker that previously tripped
            Assert.IsTrue(randoBreaker.IsOpen); // verify the new breaker is open, even though it hasn't tripped

            // TODO: This is a behavior test for synchronous order, thread probably doesn't matter here...
        }
예제 #2
0
        public void TestFixtureSetUp()
        {
            // wire-up an Action delegate, this is designed to throw exceptions...
            this.aFailingAction = this.DoException;

            // wire-up a circuit breaker
            this.sbBreaker = new Breaker(typeof(StringBuilder));

            // verify core functionality before running other tests
            this.VerifyClosedAndOpenBehavior();
        }
예제 #3
0
        static void Main(string[] args)
        {
            var testData = new List<Test>();
            testData.Add(new Test { Id = 1, Desc = "Fu" });
            testData.Add(new Test { Id = 2, Desc = "bar" });

            var breaker = new Breaker(typeof(StringBuilder));

            Action someAction;
            someAction = someMethod;

            breaker.ExecuteAction(someAction);
        }
예제 #4
0
 public AbstractCommand(ICircuit circuit)
 {
     Circuit = circuit;
     Breaker = new Breaker(Circuit);
 }
예제 #5
0
 public void VerifyNewBreakerObservesStateChangesFromOtherClients()
 {
     var randoBreaker = new Breaker(typeof(SomeRandomClass)); // setup a new breaker
     var aThread = new Thread(DoThreadWork); // trip a breaker tracking the same type in a different thread
     Assert.IsTrue(randoBreaker.IsOpen); // verify the breaker is open, even though a client in another thread tripped it
 }
예제 #6
0
 private void DoThreadWork()
 {
     var randoBreaker = new Breaker(typeof(SomeRandomClass)); // setup a new breaker
     Assert.IsTrue(randoBreaker.IsClosed, "This random breaker is open and should be closed!");
     try
     {
         randoBreaker.ExecuteAction(this.DoException);
     }
     catch (CircuitBreakerOpenException)
     {
         // nom;
     }
 }