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:
26
tests/NATS.Server.Mqtt.Tests/Mqtt/MqttPacketParserTests.cs
Normal file
26
tests/NATS.Server.Mqtt.Tests/Mqtt/MqttPacketParserTests.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using NATS.Server.Mqtt;
|
||||
|
||||
namespace NATS.Server.Mqtt.Tests.Mqtt;
|
||||
|
||||
public class MqttPacketParserTests
|
||||
{
|
||||
[Fact]
|
||||
public void Connect_packet_fixed_header_and_remaining_length_parse_correctly()
|
||||
{
|
||||
var packet = MqttPacketReader.Read(ConnectPacketBytes.Sample);
|
||||
packet.Type.ShouldBe(MqttControlPacketType.Connect);
|
||||
packet.RemainingLength.ShouldBe(12);
|
||||
packet.Payload.Length.ShouldBe(12);
|
||||
}
|
||||
|
||||
private static class ConnectPacketBytes
|
||||
{
|
||||
public static readonly byte[] Sample =
|
||||
[
|
||||
0x10, 0x0C, // CONNECT + remaining length
|
||||
0x00, 0x04, (byte)'M', (byte)'Q', (byte)'T', (byte)'T',
|
||||
0x04, 0x02, 0x00, 0x3C, // protocol level/flags/keepalive
|
||||
0x00, 0x00, // empty client id
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user