예제 #1
0
        public void when_writing_invalid_subscribe_ack_packet_then_fails(string jsonPath)
        {
            jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath);

            SubscribeAckFormatter formatter    = new SubscribeAckFormatter();
            SubscribeAck          subscribeAck = Packet.ReadPacket <SubscribeAck>(jsonPath);

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

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

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

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

            Assert.True(ex.InnerException is MqttProtocolViolationException);
        }
예제 #3
0
        public async Task when_writing_subscribe_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);
            SubscribeAckFormatter formatter    = new SubscribeAckFormatter();
            SubscribeAck          subscribeAck = Packet.ReadPacket <SubscribeAck>(jsonPath);

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

            expectedPacket.Should().BeEquivalentTo(result);
        }
예제 #4
0
        public async Task when_reading_subscribe_ack_packet_then_succeeds(string packetPath, string jsonPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);

            SubscribeAck          expectedSubscribeAck = Packet.ReadPacket <SubscribeAck>(jsonPath);
            SubscribeAckFormatter formatter            = new SubscribeAckFormatter();

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

            IPacket result = await formatter.FormatAsync(packet);

            expectedSubscribeAck.Should().Be(result);
        }
        public async Task when_writing_subscribe_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 SubscribeAckFormatter();
            var subscribeAck   = Packet.ReadPacket <SubscribeAck> (jsonPath);

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

            Assert.Equal(expectedPacket, result);
        }