mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-25 07:41:32 +08:00
Squashed commit of the following:
commit 0cbf50427ca6fb343cfa22ccbcd06aad5ea2b4c2 Author: Christian <6939810+chkr1011@users.noreply.github.com> Date: Mon Jun 20 21:02:50 2022 +0200 Fix firing of _ClientSubscribedTopicAsync_ event.
This commit is contained in:
@@ -12,6 +12,7 @@ using MQTTnet.Formatter;
|
||||
using MQTTnet.Implementations;
|
||||
using MQTTnet.Packets;
|
||||
using MQTTnet.Protocol;
|
||||
using MQTTnet.Server;
|
||||
|
||||
namespace MQTTnet.Tests.Server
|
||||
{
|
||||
@@ -45,6 +46,30 @@ namespace MQTTnet.Tests.Server
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Enqueue_Message_After_Subscription()
|
||||
{
|
||||
using (var testEnvironment = CreateTestEnvironment())
|
||||
{
|
||||
var server = await testEnvironment.StartServer();
|
||||
|
||||
server.ClientSubscribedTopicAsync += e =>
|
||||
{
|
||||
server.InjectApplicationMessage(new InjectedMqttApplicationMessage(new MqttApplicationMessageBuilder().WithTopic("test_topic").Build()));
|
||||
return PlatformAbstractionLayer.CompletedTask;
|
||||
};
|
||||
|
||||
var client = await testEnvironment.ConnectClient();
|
||||
var receivedMessages = testEnvironment.CreateApplicationMessageHandler(client);
|
||||
|
||||
await client.SubscribeAsync("test_topic");
|
||||
|
||||
await LongTestDelay();
|
||||
|
||||
Assert.AreEqual(1, receivedMessages.ReceivedEventArgs.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public async Task Intercept_Subscription()
|
||||
{
|
||||
@@ -101,7 +126,7 @@ namespace MQTTnet.Tests.Server
|
||||
.WithTopicFilter("c", MqttQualityOfServiceLevel.ExactlyOnce)
|
||||
.WithTopicFilter("d")
|
||||
.Build();
|
||||
|
||||
|
||||
var response = await client.SubscribeAsync(subscribeOptions);
|
||||
|
||||
Assert.AreEqual(subscribeOptions.TopicFilters.Count, response.Items.Count);
|
||||
|
||||
Reference in New Issue
Block a user