Fix Managed Client should dispose inner mqtt client #527

This commit is contained in:
Berni
2019-02-07 16:46:58 +01:00
parent 6c5c9e5bf2
commit de3a39bdc2
3 changed files with 55 additions and 10 deletions
@@ -29,6 +29,10 @@ namespace MQTTnet.Tests.Mockups
public int ServerPort { get; set; } = 1888;
public IMqttNetLogger ServerLogger => _serverLogger;
public IMqttNetLogger ClientLogger => _clientLogger;
public TestEnvironment()
{
_serverLogger.LogMessagePublished += (s, e) =>
@@ -56,7 +60,9 @@ namespace MQTTnet.Tests.Mockups
public IMqttClient CreateClient()
{
return _mqttFactory.CreateMqttClient(_clientLogger);
var client = _mqttFactory.CreateMqttClient(_clientLogger);
_clients.Add(client);
return client;
}
public Task<IMqttServer> StartServerAsync()
@@ -84,10 +90,9 @@ namespace MQTTnet.Tests.Mockups
public async Task<IMqttClient> ConnectClientAsync(MqttClientOptionsBuilder options)
{
var client = _mqttFactory.CreateMqttClient(_clientLogger);
var client = CreateClient();
await client.ConnectAsync(options.WithTcpServer("localhost", ServerPort).Build());
_clients.Add(client);
return client;
}
@@ -135,4 +140,4 @@ namespace MQTTnet.Tests.Mockups
}
}
}
}
}