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); }
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); }
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); }
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); }
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); }