Пример #1
0
        public async Task ConnectingState_SendsHandleConnectionDisconnectedCommand()
        {
            // Act
            _state.StartTimer();
            _timer.OnTimeOut();

            // Assert
            _timer.StartedWithAction.Should().BeTrue();
            _context.ShouldQueueCommand <HandleConnectingDisconnectedCommand>();
        }
Пример #2
0
        public async Task AfterTimeoutExpires_ShouldForceStateToClosed()
        {
            var state = GetState(connectedTransport: true);

            state.StartTimer();

            _timer.StartedWithAction.Should().BeTrue();
            _timer.OnTimeOut();

            _context.ShouldQueueCommand <SetClosedStateCommand>();
        }
Пример #3
0
        public async Task ShouldRetryConnection()
        {
            _context.Transport = new FakeTransport(TransportState.Initialized);

            // Act
            _state.StartTimer();
            _timer.StartedWithAction.Should().BeTrue();
            _timer.OnTimeOut();

            // Assert
            _context.ShouldQueueCommand <SetConnectingStateCommand>();
        }
Пример #4
0
        public async Task ShouldRetyConnection()
        {
            _context.Transport = new FakeTransport(TransportState.Initialized);

            // Act
            await _state.OnAttachToContext();

            _timer.StartedWithAction.Should().BeTrue();
            _timer.OnTimeOut();

            // Assert
            _context.StateShouldBe <ConnectionConnectingState>();
        }
Пример #5
0
        public async Task ConnectingState_ForceDisconnect()
        {
            // Arrange
            _context.Transport = new FakeTransport()
            {
                State = TransportState.Initialized
            };

            // Act
            await _state.OnAttachToContext();

            _timer.OnTimeOut();

            // Assert
            _timer.StartedWithAction.Should().BeTrue();
            _context.HandledConnectionFailureCalled.Should().BeTrue();
        }
Пример #6
0
        public async Task AfterAnInterval_ShouldRetryConnection()
        {
            // Arrange
            var transport = new FakeTransport {
                State = TransportState.Initialized
            };

            _context.Transport = transport;
            var state = GetState(ErrorInfo.ReasonClosed);

            // Act
            state.StartTimer();
            _timer.OnTimeOut();

            // Assert
            _timer.StartedWithAction.Should().BeTrue();
            _context.ShouldQueueCommand <SetConnectingStateCommand>();
        }
Пример #7
0
        public async Task AfterAnInterval_ShouldRetryConnection()
        {
            // Arrange
            var transport = new FakeTransport()
            {
                State = TransportState.Initialized
            };

            _context.Transport = transport;
            var state = GetState(ErrorInfo.ReasonClosed);

            // Act
            await state.OnAttachToContext();

            _timer.OnTimeOut();

            // Assert
            _timer.StartedWithAction.Should().BeTrue();
            _context.StateShouldBe <ConnectionConnectingState>();
        }