Ejemplo n.º 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...
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
0
 public AbstractCommand(ICircuit circuit)
 {
     Circuit = circuit;
     Breaker = new Breaker(Circuit);
 }
Ejemplo n.º 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
 }
Ejemplo n.º 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;
     }
 }