Fix unit tests to allow release builds.

This commit is contained in:
Christian Kratky
2018-07-27 17:20:19 +02:00
parent 61b324043a
commit b4f90decc7
2 changed files with 6 additions and 4 deletions
@@ -1,3 +1,5 @@
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
#if DEBUG
[assembly:InternalsVisibleTo("MQTTnet.Core.Tests")] [assembly:InternalsVisibleTo("MQTTnet.Core.Tests")]
#endif
+4 -4
View File
@@ -8,8 +8,6 @@ using MQTTnet.Client;
using MQTTnet.Diagnostics; using MQTTnet.Diagnostics;
using MQTTnet.Exceptions; using MQTTnet.Exceptions;
using MQTTnet.Packets; using MQTTnet.Packets;
using MQTTnet.Implementations;
using MQTTnet.Server;
namespace MQTTnet.Core.Tests namespace MQTTnet.Core.Tests
{ {
@@ -41,6 +39,7 @@ namespace MQTTnet.Core.Tests
Assert.IsInstanceOfType(ex.InnerException, typeof(SocketException)); Assert.IsInstanceOfType(ex.InnerException, typeof(SocketException));
} }
#if DEBUG
[TestMethod] [TestMethod]
public async Task ClientCleanupOnAuthentificationFails() public async Task ClientCleanupOnAuthentificationFails()
{ {
@@ -55,11 +54,11 @@ namespace MQTTnet.Core.Tests
}); });
var fake = new TestMqttCommunicationAdapterFactory(channel); var fake = new TestMqttCommunicationAdapterFactory(channel);
var client = new MqttClient(fake, new MqttNetLogger()); var client = new MqttClient(fake, new MqttNetLogger());
try try
{ {
await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("any-server").Build()); await client.ConnectAsync(new MqttClientOptionsBuilder().WithTcpServer("any-server").Build());
@@ -72,5 +71,6 @@ namespace MQTTnet.Core.Tests
Assert.IsTrue(client._packetReceiverTask == null || client._packetReceiverTask.IsCompleted, "receive loop not completed"); Assert.IsTrue(client._packetReceiverTask == null || client._packetReceiverTask.IsCompleted, "receive loop not completed");
Assert.IsTrue(client._keepAliveMessageSenderTask == null || client._keepAliveMessageSenderTask.IsCompleted, "keepalive loop not completed"); Assert.IsTrue(client._keepAliveMessageSenderTask == null || client._keepAliveMessageSenderTask.IsCompleted, "keepalive loop not completed");
} }
#endif
} }
} }