From f9c3014e52a1db4f53f46340a6a772a538411746 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 15 Nov 2020 14:34:59 +0100 Subject: [PATCH] Fix Unit Tests. --- Source/MQTTnet/Server/MqttClientConnection.cs | 2 +- Tests/MQTTnet.Core.Tests/Server_Tests.cs | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/MQTTnet/Server/MqttClientConnection.cs b/Source/MQTTnet/Server/MqttClientConnection.cs index 2945bc2..6a83db0 100644 --- a/Source/MQTTnet/Server/MqttClientConnection.cs +++ b/Source/MQTTnet/Server/MqttClientConnection.cs @@ -104,7 +104,7 @@ namespace MQTTnet.Server } catch (Exception exception) { - _logger.Error(exception, "Client '{0}': Error while sending DISCONNECT packet after takeover.", ClientId); + _logger.Warning(exception, "Client '{0}': Error while sending DISCONNECT packet after takeover.", ClientId); } } diff --git a/Tests/MQTTnet.Core.Tests/Server_Tests.cs b/Tests/MQTTnet.Core.Tests/Server_Tests.cs index efd4f7a..bc21e13 100644 --- a/Tests/MQTTnet.Core.Tests/Server_Tests.cs +++ b/Tests/MQTTnet.Core.Tests/Server_Tests.cs @@ -304,7 +304,7 @@ namespace MQTTnet.Tests await c2.PublishAsync(messageBuilder.Build()).ConfigureAwait(false); } - SpinWait.SpinUntil(() => receivedMessagesCount == 500, 5000); + SpinWait.SpinUntil(() => receivedMessagesCount == 500, TimeSpan.FromSeconds(15)); Assert.AreEqual(500, receivedMessagesCount); } @@ -445,7 +445,7 @@ namespace MQTTnet.Tests await c1.PublishAsync(message).ConfigureAwait(false); } - SpinWait.SpinUntil(() => receivedMessagesCount == 1000, TimeSpan.FromSeconds(10)); + SpinWait.SpinUntil(() => receivedMessagesCount == 1000, TimeSpan.FromSeconds(15)); Assert.AreEqual(1000, receivedMessagesCount); } @@ -953,7 +953,8 @@ namespace MQTTnet.Tests byte[] receivedBody = null; - await testEnvironment.StartServerAsync(new MqttServerOptionsBuilder()); + await testEnvironment.StartServerAsync(); + var client1 = await testEnvironment.ConnectClientAsync(); client1.UseApplicationMessageReceivedHandler(c => { @@ -965,7 +966,7 @@ namespace MQTTnet.Tests var client2 = await testEnvironment.ConnectClientAsync(); await client2.PublishAsync("string", longBody); - await Task.Delay(500); + await Task.Delay(TimeSpan.FromSeconds(5)); Assert.IsTrue(longBody.SequenceEqual(receivedBody ?? new byte[0])); }