using NATS.Server.Mqtt; namespace NATS.Server.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 ]; } }