Fix null ref exception in low level client.

This commit is contained in:
Christian Kratky
2020-08-05 20:49:11 +02:00
parent 4f51a238b3
commit 6b6627f823
3 changed files with 20 additions and 6 deletions
@@ -8,6 +8,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MQTTnet.Exceptions;
namespace MQTTnet.Tests
{
@@ -16,6 +17,18 @@ namespace MQTTnet.Tests
{
public TestContext TestContext { get; set; }
[TestMethod]
[ExpectedException(typeof(MqttCommunicationException))]
public async Task Connect_To_Not_Existing_Server()
{
var client = new MqttFactory().CreateLowLevelMqttClient();
var options = new MqttClientOptionsBuilder()
.WithTcpServer("localhost")
.Build();
await client.ConnectAsync(options, CancellationToken.None).ConfigureAwait(false);
}
[TestMethod]
public async Task Connect_And_Disconnect()
{
@@ -78,7 +91,7 @@ namespace MQTTnet.Tests
async Task<MqttConnAckPacket> Authenticate(ILowLevelMqttClient client)
{
await client.SendAsync(new MqttConnectPacket()
await client.SendAsync(new MqttConnectPacket
{
CleanSession = true,
ClientId = TestContext.TestName,