diff --git a/Tests/MQTTnet.Core.Tests/MqttClient_Tests.cs b/Tests/MQTTnet.Core.Tests/MqttClient_Tests.cs index 155b55e..c1245ce 100644 --- a/Tests/MQTTnet.Core.Tests/MqttClient_Tests.cs +++ b/Tests/MQTTnet.Core.Tests/MqttClient_Tests.cs @@ -158,6 +158,25 @@ namespace MQTTnet.Tests } } + [TestMethod] + public async Task Fire_Disconnected_Event_On_Server_Shutdown() + { + using (var testEnvironment = new TestEnvironment()) + { + var server = await testEnvironment.StartServerAsync(); + var client = await testEnvironment.ConnectClientAsync(); + + var handlerFired = false; + client.UseDisconnectedHandler(e => handlerFired = true); + + await server.StopAsync(); + + await Task.Delay(4000); + + Assert.IsTrue(handlerFired); + } + } + [TestMethod] public async Task Disconnect_Event_Contains_Exception() {