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

            ConnectFormatter formatter = new ConnectFormatter();
            Connect          connect   = Packet.ReadPacket <Connect>(jsonPath);

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

            Assert.True(ex.InnerException is MqttException);
        }
예제 #2
0
        public void when_reading_invalid_client_id_in_connect_packet_then_fails(string packetPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

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

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

            Assert.True(ex.InnerException is MqttConnectionException);
        }
        public async Task when_writing_connect_packet_then_succeeds(string jsonPath, string packetPath)
        {
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            byte[]           expectedPacket = Packet.ReadAllBytes(packetPath);
            ConnectFormatter formatter      = new ConnectFormatter();
            Connect          connect        = Packet.ReadPacket <Connect>(jsonPath);

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

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

            Connect          expectedConnect = Packet.ReadPacket <Connect>(jsonPath);
            ConnectFormatter formatter       = new ConnectFormatter();

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

            IPacket result = await formatter.FormatAsync(packet);

            expectedConnect.Should().Be(result);
        }
예제 #5
0
        public async Task when_writing_connect_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 ConnectFormatter();
            var connect        = Packet.ReadPacket <Connect> (jsonPath);

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

            Assert.Equal(expectedPacket, result);
        }