Esempio n. 1
0
        private void SerializeAndCompare(MqttBasePacket packet, string expectedBase64Value)
        {
            var serializer = new DefaultMqttV311PacketSerializer();
            var channel    = new TestChannel();

            serializer.SerializeAsync(packet, channel).Wait();
            var buffer = channel.ToArray();

            Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(buffer));
        }
Esempio n. 2
0
        private void DeserializeAndCompare(MqttBasePacket packet, string expectedBase64Value)
        {
            var serializer = new DefaultMqttV311PacketSerializer();

            var channel1 = new TestChannel();

            serializer.SerializeAsync(packet, channel1).Wait();
            var buffer1 = channel1.ToArray();

            var channel2           = new TestChannel(buffer1);
            var deserializedPacket = serializer.DeserializeAsync(channel2).Result;
            var buffer2            = channel2.ToArray();

            var channel3 = new TestChannel(buffer2);

            serializer.SerializeAsync(deserializedPacket, channel3).Wait();

            Assert.AreEqual(expectedBase64Value, Convert.ToBase64String(channel3.ToArray()));
        }