public void Setup() { this.stateDetector = new ConnectionStateDetector(TestAction, 0, 1); IFavorite fakeFavorite = CreateFakeFavorite(); this.stateDetector.AssignFavorite(fakeFavorite); this.stateDetector.Reconnected += this.StateDetector_Reconnected; this.stateDetector.Start(); }
public void FailingTest_TryReconnect_FiresReconnectExpired() { this.stateDetector = new ConnectionStateDetector((serverName, port) => { throw new Exception("Failing test simulation"); }, 0, 1); IFavorite fakeFavorite = CreateFakeFavorite(); this.stateDetector.AssignFavorite(fakeFavorite); bool expired = false; var runExpired = new ManualResetEvent(false); this.stateDetector.ReconnectExpired += (sender, args) => { expired = true; runExpired.Set(); }; this.stateDetector.Start(); runExpired.WaitOne(); Assert.IsTrue(expired, "Failing connection longer than retry count has to raise expired event."); }