public void ConnectToInvalidPortInFaultedStateAfterConnectionException() { var ch = new SynchronousMqttConnectionHandler(); Assert.Throws<ConnectionException>(() => ch.Connect(mockBrokerAddress, badPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); Assert.Equal<ConnectionState>(ConnectionState.Faulted, ch.ConnectionState); }
public void ConnectToBadHostNameInFaultedStateAfterConnectionException() { var ch = new SynchronousMqttConnectionHandler(); Assert.Throws<ConnectionException>(() => ch.Connect(nonExistantHostName, mockBrokerPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); Assert.Equal<ConnectionState>(ConnectionState.Faulted, ch.ConnectionState); }
public void ConnectWithNoConnectAckThrowsExceptionAndSetsConnectionToFaulted() { var ch = new SynchronousMqttConnectionHandler(); var ex = Assert.Throws<ConnectionException>(() => ch.Connect(mockBrokerAddress, mockBrokerPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); Console.WriteLine("Exception Message Received {0}", ex.ToString()); Assert.Equal<ConnectionState>(ConnectionState.Faulted, ch.ConnectionState); }
public void SuccessfullResponseCausesConnectionStateConnected() { // register a method to process the Connect message and respond with a ConnectAck message broker.SetMessageHandler((messageArrived) => { MqttConnectMessage connect = (MqttConnectMessage)MqttMessage.CreateFrom(messageArrived); MqttConnectAckMessage ack = new MqttConnectAckMessage().WithReturnCode(MqttConnectReturnCode.ConnectionAccepted); broker.SendMessage(ack); }); var ch = new SynchronousMqttConnectionHandler(); Assert.Equal<ConnectionState>(ConnectionState.Connected, ch.Connect(mockBrokerAddress, mockBrokerPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); }
public void ConnectToInvalidPortThrowsConnectionException() { var ch = new SynchronousMqttConnectionHandler(); Assert.Throws<ConnectionException>(() => ch.Connect(mockBrokerAddress, badPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); }
public void ConnectToBadHostNameThrowsConnectionException() { var ch = new SynchronousMqttConnectionHandler(); Assert.Throws<ConnectionException>(() => ch.Connect(nonExistantHostName, mockBrokerPort, new MqttConnectMessage().WithClientIdentifier(testClientId))); }