mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-11-05 14:02:55 +08:00
Add interceptor for client subscriptions
This commit is contained in:
@@ -245,10 +245,9 @@ namespace MQTTnet.Core.Tests
|
||||
[TestMethod]
|
||||
public async Task MqttServer_InterceptMessage()
|
||||
{
|
||||
MqttApplicationMessage Interceptor(MqttApplicationMessage message)
|
||||
void Interceptor(MqttApplicationMessageInterceptorContext context)
|
||||
{
|
||||
message.Payload = Encoding.ASCII.GetBytes("extended");
|
||||
return message;
|
||||
context.ApplicationMessage.Payload = Encoding.ASCII.GetBytes("extended");
|
||||
}
|
||||
|
||||
var serverAdapter = new TestMqttServerAdapter();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using MQTTnet.Core.Packets;
|
||||
using MQTTnet.Core.Protocol;
|
||||
using MQTTnet.Core.Server;
|
||||
@@ -11,7 +12,7 @@ namespace MQTTnet.Core.Tests
|
||||
[TestMethod]
|
||||
public void MqttSubscriptionsManager_SubscribeSingleSuccess()
|
||||
{
|
||||
var sm = new MqttClientSubscriptionsManager();
|
||||
var sm = new MqttClientSubscriptionsManager(new OptionsWrapper<MqttServerOptions>(new MqttServerOptions()));
|
||||
|
||||
var sp = new MqttSubscribePacket();
|
||||
sp.TopicFilters.Add(new TopicFilter("A/B/C", MqttQualityOfServiceLevel.AtMostOnce));
|
||||
@@ -30,7 +31,7 @@ namespace MQTTnet.Core.Tests
|
||||
[TestMethod]
|
||||
public void MqttSubscriptionsManager_SubscribeSingleNoSuccess()
|
||||
{
|
||||
var sm = new MqttClientSubscriptionsManager();
|
||||
var sm = new MqttClientSubscriptionsManager(new OptionsWrapper<MqttServerOptions>(new MqttServerOptions()));
|
||||
|
||||
var sp = new MqttSubscribePacket();
|
||||
sp.TopicFilters.Add(new TopicFilter("A/B/C", MqttQualityOfServiceLevel.AtMostOnce));
|
||||
@@ -49,7 +50,7 @@ namespace MQTTnet.Core.Tests
|
||||
[TestMethod]
|
||||
public void MqttSubscriptionsManager_SubscribeAndUnsubscribeSingle()
|
||||
{
|
||||
var sm = new MqttClientSubscriptionsManager();
|
||||
var sm = new MqttClientSubscriptionsManager(new OptionsWrapper<MqttServerOptions>(new MqttServerOptions()));
|
||||
|
||||
var sp = new MqttSubscribePacket();
|
||||
sp.TopicFilters.Add(new TopicFilter("A/B/C", MqttQualityOfServiceLevel.AtMostOnce));
|
||||
|
||||
Reference in New Issue
Block a user