public void when_reading_invalid_publish_complete_packet_then_fails(string packetPath) { packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); var formatter = new FlowPacketFormatter <PublishComplete> (MqttPacketType.PublishComplete, id => new PublishComplete(id)); var packet = Packet.ReadAllBytes(packetPath); var ex = Assert.Throws <AggregateException> (() => formatter.FormatAsync(packet).Wait()); Assert.True(ex.InnerException is MqttException); }
public void when_reading_invalid_unsubscribe_ack_packet_then_fails(string packetPath) { packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); FlowPacketFormatter <UnsubscribeAck> formatter = new FlowPacketFormatter <UnsubscribeAck>(MqttPacketType.UnsubscribeAck, id => new UnsubscribeAck(id)); byte[] packet = Packet.ReadAllBytes(packetPath); AggregateException ex = Assert.Throws <AggregateException>(() => formatter.FormatAsync(packet).Wait()); Assert.True(ex.InnerException is MqttException); }
public async Task when_writing_publish_complete_packet_then_succeeds(string jsonPath, string packetPath) { jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath); packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); byte[] expectedPacket = Packet.ReadAllBytes(packetPath); FlowPacketFormatter <PublishComplete> formatter = new FlowPacketFormatter <PublishComplete>(MqttPacketType.PublishComplete, id => new PublishComplete(id)); PublishComplete publishComplete = Packet.ReadPacket <PublishComplete>(jsonPath); byte[] result = await formatter.FormatAsync(publishComplete); expectedPacket.Should().BeEquivalentTo(result); }
public async Task when_writing_unsubscribe_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); FlowPacketFormatter <UnsubscribeAck> formatter = new FlowPacketFormatter <UnsubscribeAck>(MqttPacketType.UnsubscribeAck, id => new UnsubscribeAck(id)); UnsubscribeAck unsubscribeAck = Packet.ReadPacket <UnsubscribeAck>(jsonPath); byte[] result = await formatter.FormatAsync(unsubscribeAck); expectedPacket.Should().BeEquivalentTo(result); }
public async Task when_writing_publish_complete_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 FlowPacketFormatter <PublishComplete>(MqttPacketType.PublishComplete, id => new PublishComplete(id)); var publishComplete = Packet.ReadPacket <PublishComplete> (jsonPath); var result = await formatter.FormatAsync(publishComplete) .ConfigureAwait(continueOnCapturedContext: false); Assert.Equal(expectedPacket, result); }
public async Task when_reading_publish_received_packet_then_succeeds(string packetPath, string jsonPath) { packetPath = Path.Combine(Environment.CurrentDirectory, packetPath); jsonPath = Path.Combine(Environment.CurrentDirectory, jsonPath); PublishReceived expectedPublishReceived = Packet.ReadPacket <PublishReceived>(jsonPath); FlowPacketFormatter <PublishReceived> formatter = new FlowPacketFormatter <PublishReceived>(MqttPacketType.PublishReceived, id => new PublishReceived(id)); byte[] packet = Packet.ReadAllBytes(packetPath); IPacket result = await formatter.FormatAsync(packet); expectedPublishReceived.Should().Be(result); }
public async Task when_writing_unsubscribe_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 FlowPacketFormatter <UnsubscribeAck>(MqttPacketType.UnsubscribeAck, id => new UnsubscribeAck(id)); var unsubscribeAck = Packet.ReadPacket <UnsubscribeAck> (jsonPath); var result = await formatter.FormatAsync(unsubscribeAck) .ConfigureAwait(continueOnCapturedContext: false); Assert.Equal(expectedPacket, result); }