refactor: extract NATS.Server.Mqtt.Tests project
Move 29 MQTT test files from NATS.Server.Tests into a dedicated NATS.Server.Mqtt.Tests project. Update namespaces, add InternalsVisibleTo, and replace Task.Delay calls with PollHelper.WaitUntilAsync for proper synchronization.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
using NATS.Server.Mqtt;
|
||||
|
||||
namespace NATS.Server.Mqtt.Tests.Mqtt;
|
||||
|
||||
public class MqttModelParityBatch3Tests
|
||||
{
|
||||
[Fact]
|
||||
public void Mqtt_helper_models_cover_go_core_shapes()
|
||||
{
|
||||
var jsa = new MqttJsa
|
||||
{
|
||||
AccountName = "A",
|
||||
ReplyPrefix = "$MQTT.JSA.A",
|
||||
Domain = "D1",
|
||||
};
|
||||
|
||||
var pubMsg = new MqttJsPubMsg
|
||||
{
|
||||
Subject = "$MQTT.msgs.s1",
|
||||
Payload = new byte[] { 1, 2, 3 },
|
||||
ReplyTo = "$MQTT.JSA.A.reply",
|
||||
};
|
||||
|
||||
var delete = new MqttRetMsgDel
|
||||
{
|
||||
Topic = "devices/x",
|
||||
Sequence = 123,
|
||||
};
|
||||
|
||||
var persisted = new MqttPersistedSession
|
||||
{
|
||||
ClientId = "c1",
|
||||
LastPacketId = 7,
|
||||
MaxAckPending = 1024,
|
||||
};
|
||||
|
||||
var retainedRef = new MqttRetainedMessageRef
|
||||
{
|
||||
StreamSequence = 88,
|
||||
Subject = "$MQTT.rmsgs.devices/x",
|
||||
};
|
||||
|
||||
var sub = new MqttSub
|
||||
{
|
||||
Filter = "devices/+",
|
||||
Qos = 1,
|
||||
JsDur = "DUR-c1",
|
||||
Prm = true,
|
||||
Reserved = false,
|
||||
};
|
||||
|
||||
var filter = new MqttFilter
|
||||
{
|
||||
Filter = "devices/#",
|
||||
Qos = 1,
|
||||
TopicToken = "devices",
|
||||
};
|
||||
|
||||
var parsedHeader = new MqttParsedPublishNatsHeader
|
||||
{
|
||||
Subject = "devices/x",
|
||||
Mapped = "devices.y",
|
||||
IsPublish = true,
|
||||
IsPubRel = false,
|
||||
};
|
||||
|
||||
jsa.AccountName.ShouldBe("A");
|
||||
pubMsg.Payload.ShouldBe(new byte[] { 1, 2, 3 });
|
||||
delete.Sequence.ShouldBe(123UL);
|
||||
persisted.MaxAckPending.ShouldBe(1024);
|
||||
retainedRef.StreamSequence.ShouldBe(88UL);
|
||||
sub.JsDur.ShouldBe("DUR-c1");
|
||||
filter.TopicToken.ShouldBe("devices");
|
||||
parsedHeader.IsPublish.ShouldBeTrue();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Retained_message_model_includes_origin_flags_and_source_fields()
|
||||
{
|
||||
var msg = new MqttRetainedMessage(
|
||||
Topic: "devices/x",
|
||||
Payload: new byte[] { 0x41, 0x42 },
|
||||
Origin: "origin-a",
|
||||
Flags: 0b_0000_0011,
|
||||
Source: "src-a");
|
||||
|
||||
msg.Topic.ShouldBe("devices/x");
|
||||
msg.Origin.ShouldBe("origin-a");
|
||||
msg.Flags.ShouldBe((byte)0b_0000_0011);
|
||||
msg.Source.ShouldBe("src-a");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user