Пример #1
0
        public void Invalidate_should_force_another_heartbeat()
        {
            SetupHeartbeatConnection();
            _subject.Initialize();

            SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Connected, TimeSpan.FromSeconds(4));

            _subject.Invalidate();

            // 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 Invalidate_should_do_everything_invalidate_is_supposed_to_do()
        {
            SetupHeartbeatConnection();
            _subject.Initialize();
            SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Connected, TimeSpan.FromSeconds(4));
            _capturedEvents.Clear();

            _subject.Invalidate();

            _connectionPool.Received().Clear();
            _subject.Description.Type.Should().Be(ServerType.Unknown);

            // 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 <ServerDescriptionChangedEvent>();
            _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();
        }
Пример #3
0
        public void Invalidate_should_do_everything_invalidate_is_supposed_to_do()
        {
            SetupHeartbeatConnection();
            _subject.Initialize();

            SpinWait.SpinUntil(() => _subject.Description.State == ServerState.Connected, TimeSpan.FromSeconds(4));

            _subject.Invalidate();

            _connectionPool.Received().Clear();
            _subject.Description.Type.Should().Be(ServerType.Unknown);

            // 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));
        }