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