From 54a0265ef9ca6ce82efdb4d6d3d061d3fad70b5f Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 1 Apr 2018 20:53:32 +0200 Subject: [PATCH] Fix UnitTests --- Tests/MQTTnet.Core.Tests/MqttServerTests.cs | 2 +- .../TestMqttCommunicationAdapter.cs | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tests/MQTTnet.Core.Tests/MqttServerTests.cs b/Tests/MQTTnet.Core.Tests/MqttServerTests.cs index 7cf8bf3..752601f 100644 --- a/Tests/MQTTnet.Core.Tests/MqttServerTests.cs +++ b/Tests/MQTTnet.Core.Tests/MqttServerTests.cs @@ -156,7 +156,7 @@ namespace MQTTnet.Core.Tests var message = new MqttApplicationMessageBuilder().WithTopic("a").WithAtLeastOnceQoS().Build(); await c1.SubscribeAsync(new TopicFilter("a", MqttQualityOfServiceLevel.AtLeastOnce)); - s.PublishAsync(message).Wait(); + await s.PublishAsync(message); await Task.Delay(500); } finally diff --git a/Tests/MQTTnet.Core.Tests/TestMqttCommunicationAdapter.cs b/Tests/MQTTnet.Core.Tests/TestMqttCommunicationAdapter.cs index 9624a90..a898f76 100644 --- a/Tests/MQTTnet.Core.Tests/TestMqttCommunicationAdapter.cs +++ b/Tests/MQTTnet.Core.Tests/TestMqttCommunicationAdapter.cs @@ -47,7 +47,17 @@ namespace MQTTnet.Core.Tests { ThrowIfPartnerIsNull(); - return Task.Run(() => _incomingPackets.Take(), cancellationToken); + return Task.Run(() => + { + try + { + return _incomingPackets.Take(cancellationToken); + } + catch + { + return null; + } + }, cancellationToken); } private void EnqueuePacketInternal(MqttBasePacket packet)