Fix wrong QoS when using MqttClientMessageQueueInterceptor #978

This commit is contained in:
Marc Sallin
2020-09-04 09:53:34 +02:00
committed by Sallin Marc, I212
parent fd789417e7
commit 7f5504b01b
2 changed files with 34 additions and 7 deletions
+26
View File
@@ -1452,5 +1452,31 @@ namespace MQTTnet.Tests
}
}
[TestMethod]
public async Task Intercept_ClientMessageQueue_Different_QoS_Of_Subscription_And_Message()
{
const string topic = "a";
using (var testEnvironment = new TestEnvironment(TestContext))
{
await testEnvironment.StartServerAsync(new MqttServerOptionsBuilder()
.WithClientMessageQueueInterceptor(c => { })); // Interceptor does nothing but has to be present.
bool receivedMessage = false;
var client = await testEnvironment.ConnectClientAsync();
client.UseApplicationMessageReceivedHandler(c =>
{
receivedMessage = true;
});
await client.SubscribeAsync(topic, MqttQualityOfServiceLevel.AtLeastOnce);
await client.PublishAsync(new MqttApplicationMessage{ Topic = topic, QualityOfServiceLevel = MqttQualityOfServiceLevel.AtMostOnce });
await Task.Delay(500);
Assert.IsTrue(receivedMessage);
}
}
}
}