public async Task when_sending_payload_with_identifier_then_receives_on_same_identifier() { MqttConfiguration configuration = new MqttConfiguration(); PrivateStream stream = new PrivateStream(configuration); int clientReceived = 0; IDisposable clientReceiver = stream .Receive(EndpointIdentifier.Client) .Subscribe(payload => { clientReceived++; }); int serverReceived = 0; IDisposable serverReceiver = stream .Receive(EndpointIdentifier.Server) .Subscribe(payload => { serverReceived++; }); stream.Send(new byte[255], EndpointIdentifier.Client); stream.Send(new byte[100], EndpointIdentifier.Client); stream.Send(new byte[30], EndpointIdentifier.Client); stream.Send(new byte[10], EndpointIdentifier.Server); stream.Send(new byte[500], EndpointIdentifier.Server); stream.Send(new byte[5], EndpointIdentifier.Server); await Task.Delay(TimeSpan.FromMilliseconds(1000)); 3.Should().Be(clientReceived); 3.Should().Be(serverReceived); }
public async Task when_sending_payload_with_identifier_then_receives_on_same_identifier() { var configuration = new MqttConfiguration(); var stream = new PrivateStream(configuration); var clientReceived = 0; var clientReceiver = stream .Receive(EndpointIdentifier.Client) .Subscribe(payload => { clientReceived++; }); var serverReceived = 0; var serverReceiver = stream .Receive(EndpointIdentifier.Server) .Subscribe(payload => { serverReceived++; }); stream.Send(new byte[255], EndpointIdentifier.Client); stream.Send(new byte[100], EndpointIdentifier.Client); stream.Send(new byte[30], EndpointIdentifier.Client); stream.Send(new byte[10], EndpointIdentifier.Server); stream.Send(new byte[500], EndpointIdentifier.Server); stream.Send(new byte[5], EndpointIdentifier.Server); await Task.Delay(TimeSpan.FromMilliseconds(1000)); Assert.Equal(3, clientReceived); Assert.Equal(3, serverReceived); }
public async Task when_sending_packet_then_stream_receives_successfully() { var configuration = new MqttConfiguration(); var stream = new PrivateStream(configuration); var channel = new PrivateChannel(stream, EndpointIdentifier.Client, configuration); var packetsReceived = 0; stream .Receive(EndpointIdentifier.Client) .Subscribe(packet => { packetsReceived++; }); await channel.SendAsync(new byte[255]); await channel.SendAsync(new byte[10]); await channel.SendAsync(new byte[34]); await channel.SendAsync(new byte[100]); await channel.SendAsync(new byte[50]); await Task.Delay(TimeSpan.FromMilliseconds(1000)); Assert.Equal(5, packetsReceived); }