Пример #1
0
        public async Task ShouldHandleInboundDisconnectedMessageAndShouldQueueSetDisconnectedStateCommand()
        {
            // Act
            bool result = await _state.OnMessageReceived(new ProtocolMessage(ProtocolMessage.MessageAction.Disconnected), null);

            // Assert
            result.Should().BeTrue();
            _context.ShouldQueueCommand <SetDisconnectedStateCommand>();
        }
Пример #2
0
        public async Task WithConnectedTransportAndInboundConnectedMessage_ShouldGoToConnected()
        {
            // Arrange
            _context.Transport = GetConnectedTransport();

            // Act
            await _state.OnMessageReceived(new ProtocolMessage(ProtocolMessage.MessageAction.Connected), null);

            // Assert
            _context.ShouldQueueCommand <SetConnectedStateCommand>();
        }
Пример #3
0
        public void WhenCloseCalled_ShouldTransitionToClosedAndTimerAborted()
        {
            // Arrange
            var state = GetState(ErrorInfo.ReasonClosed);

            // Act
            state.Close();

            // Assert
            _context.ShouldQueueCommand <SetClosedStateCommand>();
            _timer.Aborted.Should().BeTrue();
        }
Пример #4
0
        public async Task ShouldRetryConnection()
        {
            _context.Transport = new FakeTransport(TransportState.Initialized);

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

            // Assert
            _context.ShouldQueueCommand <SetConnectingStateCommand>();
        }