コード例 #1
0
        public void when_writing_invalid_unsubscribe_packet_then_fails(string jsonPath)
        {
            jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath);

            var formatter   = new UnsubscribeFormatter();
            var unsubscribe = Packet.ReadPacket <Unsubscribe> (jsonPath);

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

            Assert.True(ex.InnerException is MqttProtocolViolationException);
        }
コード例 #2
0
        public void when_reading_invalid_topic_in_unsubscribe_packet_then_fails(string packetPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            var formatter = new UnsubscribeFormatter();
            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_unsubscribe_packet_then_succeeds(string jsonPath, string packetPath)
        {
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);

            byte[] expectedPacket            = Packet.ReadAllBytes(packetPath);
            UnsubscribeFormatter formatter   = new UnsubscribeFormatter();
            Unsubscribe          unsubscribe = Packet.ReadPacket <Unsubscribe>(jsonPath);

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

            expectedPacket.Should().BeEquivalentTo(result);
        }
コード例 #4
0
        public async Task when_writing_unsubscribe_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 UnsubscribeFormatter();
            var unsubscribe    = Packet.ReadPacket <Unsubscribe> (jsonPath);

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

            Assert.Equal(expectedPacket, result);
        }
コード例 #5
0
        public async Task when_reading_unsubscribe_packet_then_succeeds(string packetPath, string jsonPath)
        {
            packetPath = Path.Combine(Environment.CurrentDirectory, packetPath);
            jsonPath   = Path.Combine(Environment.CurrentDirectory, jsonPath);

            Unsubscribe          expectedUnsubscribe = Packet.ReadPacket <Unsubscribe>(jsonPath);
            UnsubscribeFormatter formatter           = new UnsubscribeFormatter();

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

            IPacket result = await formatter.FormatAsync(packet);

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