public async Task Random_packets_sent_only_before_first_packet_to_first_destination()
        {
            var settings = new RandomFirstSessionPrefixInterceptor.Settings {
                CountMin = 2, CountMax = 2
            };
            var interceptor = new RandomFirstSessionPrefixInterceptor(this._bufferPool, settings, new NullLoggerFactory());
            var client      = new FakeUdpClient();

            var destinationEndPoint = FakeEndPoints.CreateRemote();

            var payload = new ArraySegment <byte>(new byte[] { 1, 2, 3, 4 });
            var isSendingHandledByInterceptor = await interceptor
                                                .TryInterceptOutgoingAsync(payload, destinationEndPoint, client)
                                                .ConfigureAwait(true);

            isSendingHandledByInterceptor.Should().BeFalse();

            payload = new ArraySegment <byte>(new byte[] { 5, 6, 7, 8 });
            isSendingHandledByInterceptor = await interceptor
                                            .TryInterceptOutgoingAsync(payload, destinationEndPoint, client)
                                            .ConfigureAwait(true);

            isSendingHandledByInterceptor.Should().BeFalse();

            var packets = client.WaitForSentPackets(2);

            packets[0].Packet.Length.Should().BeInRange(settings.BytesMin, settings.BytesMax);
            packets[1].Packet.Length.Should().BeInRange(settings.BytesMin, settings.BytesMax);
        }
        public async Task Written_packet_can_be_retrieved()
        {
            using (var client = new FakeUdpClient())
            {
                var destination = FakeEndPoints.CreateRemote();
                var packet      = new byte[] { 1, 2, 3, 4, 5 };
                await client.SendAsync(packet, 0, packet.Length, destination).ConfigureAwait(true);

                var received = client.WaitForSentPackets(1).First();
                received.Destination.Should().Be(destination);
                received.Packet.Should().Equal(1, 2, 3, 4, 5);
            }
        }