public void RequestHeartbeat_should_force_another_heartbeat() { SetupHeartbeatConnection(); _subject.Initialize(); SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Connected, TimeSpan.FromSeconds(4)); _subject.RequestHeartbeat(); // the next requests down heartbeat connection will fail, so the state should // go back to disconnected SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Disconnected, TimeSpan.FromSeconds(4)); }
public void RequestHeartbeat_should_force_another_heartbeat() { SetupHeartbeatConnection(); _subject.Initialize(); SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Connected, TimeSpan.FromSeconds(4)); _capturedEvents.Clear(); _subject.RequestHeartbeat(); // the next requests down heartbeat connection will fail, so the state should // go back to disconnected SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Disconnected, TimeSpan.FromSeconds(4)); // when heart fails, we immediately attempt a second, hence the multiple events... _capturedEvents.Next().Should().BeOfType <ServerHeartbeatStartedEvent>(); _capturedEvents.Next().Should().BeOfType <ServerHeartbeatFailedEvent>(); _capturedEvents.Next().Should().BeOfType <ServerHeartbeatStartedEvent>(); _capturedEvents.Next().Should().BeOfType <ServerHeartbeatFailedEvent>(); _capturedEvents.Next().Should().BeOfType <ServerDescriptionChangedEvent>(); _capturedEvents.Any().Should().BeFalse(); }