Refactor code.

This commit is contained in:
Christian Kratky
2020-05-01 21:47:25 +02:00
parent 48d0344a40
commit 2a421d1d42
8 changed files with 36 additions and 64 deletions
+8 -2
View File
@@ -36,7 +36,7 @@ namespace MQTTnet.Tests
public async Task Connect_To_Invalid_Server_Port_Not_Opened()
{
var client = new MqttFactory().CreateMqttClient();
await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", 12345).WithCommunicationTimeout(TimeSpan.FromSeconds(2)).Build());
await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("127.0.0.1", 12345).WithCommunicationTimeout(TimeSpan.FromSeconds(5)).Build());
}
[TestMethod]
@@ -115,7 +115,13 @@ namespace MQTTnet.Tests
}
});
client2.UseApplicationMessageReceivedHandler(async c => { await client2.PublishAsync("reply", null, MqttQualityOfServiceLevel.AtLeastOnce); });
client2.UseApplicationMessageReceivedHandler(async c =>
{
// Use AtMostOnce here because with QoS 1 or even QoS 2 the process waits for
// the ACK etc. The problem is that the SpinUntil below only waits until the
// flag is set. It does not wait until the client has sent the ACK
await client2.PublishAsync("reply", null, MqttQualityOfServiceLevel.AtMostOnce);
});
await client1.PublishAsync("request", null, MqttQualityOfServiceLevel.AtLeastOnce);