Example #1
0
 public Task CreateTransport()
 {
     CreateTransportCalled = true;
     if (AllowTransportCreating)
     {
         Transport = new FakeTransport();
     }
     return(TaskConstants.BooleanTrue);
 }
Example #2
0
        //When the closing state is initialised a Close message is sent
        public async Task OnAttachedToTransport_ShouldSendClosedMessage()
        {
            // Arrange
            var transport = new FakeTransport()
            {
                State = TransportState.Connected
            };

            _context.Transport = transport;
            // Act
            await _state.OnAttachToContext();

            // Assert
            _context.LastMessageSent.Action.Should().Be(ProtocolMessage.MessageAction.Close);
        }
Example #3
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>();
        }
Example #4
0
        public async Task WhenMessageReceived_ForceDisconnectNotAppliedAndTimerShouldBeAborted(ProtocolMessage.MessageAction action)
        {
            // Arrange
            var transport = new FakeTransport()
            {
                State = TransportState.Initialized
            };

            _context.Transport = transport;

            // Act
            await _state.OnAttachToContext();

            transport.State = TransportState.Connected;
            await _state.OnMessageReceived(new ProtocolMessage(action));

            // Assert
            _timer.StartedWithAction.Should().BeTrue();
            _timer.Aborted.Should().BeTrue();
        }
        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>();
        }
        public async Task WhenDisconnectedWithFallback_ShouldRetryConnectionImmediately()
        {
            // Arrange
            // Arrange
            var transport = new FakeTransport()
            {
                State = TransportState.Initialized
            };

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

            state.RetryInstantly = true;

            // Act
            await state.OnAttachToContext();

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