public void when_writing_invalid_connect_ack_packet_then_fails(string jsonPath)
        {
            jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath);

            var formatter  = new ConnectAckFormatter();
            var connectAck = Packet.ReadPacket <ConnectAck> (jsonPath);

            var ex = Assert.Throws <AggregateException> (() => formatter.FormatAsync(connectAck).Wait());

            Assert.True(ex.InnerException is MqttException);
        }
        public void when_reading_invalid_connect_ack_packet_then_fails(string packetPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            var formatter = new ConnectAckFormatter();
            var packet    = Packet.ReadAllBytes(packetPath);

            var ex = Assert.Throws <AggregateException> (() => formatter.FormatAsync(packet).Wait());

            Assert.True(ex.InnerException is MqttException);
        }
Example #3
0
        public async Task when_writing_connect_ack_packet_then_succeeds(string jsonPath, string packetPath)
        {
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            byte[] expectedPacket          = Packet.ReadAllBytes(packetPath);
            ConnectAckFormatter formatter  = new ConnectAckFormatter();
            ConnectAck          connectAck = Packet.ReadPacket <ConnectAck>(jsonPath);

            byte[] result = await formatter.FormatAsync(connectAck);

            expectedPacket.Should().BeEquivalentTo(result);
        }
        public async Task when_writing_connect_ack_packet_then_succeeds(string jsonPath, string packetPath)
        {
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            var expectedPacket = Packet.ReadAllBytes(packetPath);
            var formatter      = new ConnectAckFormatter();
            var connectAck     = Packet.ReadPacket <ConnectAck> (jsonPath);

            var result = await formatter.FormatAsync(connectAck)
                         .ConfigureAwait(continueOnCapturedContext: false);

            Assert.Equal(expectedPacket, result);
        }
Example #5
0
        public async Task when_reading_connect_ack_packet_then_succeeds(string packetPath, string jsonPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);

            ConnectAck          expectedConnectAck = Packet.ReadPacket <ConnectAck>(jsonPath);
            ConnectAckFormatter formatter          = new ConnectAckFormatter();

            byte[] packet = Packet.ReadAllBytes(packetPath);

            IPacket result = await formatter.FormatAsync(packet);

            expectedConnectAck.Should().Be(result);
        }