Example #1
0
        async Task DoReceive(bool slowOutgoing, bool slowIncoming)
        {
            Incoming.SlowConnection = slowIncoming;
            Outgoing.SlowConnection = slowOutgoing;

            int sent = 0;

            buffer = new byte [data.Length];

            var task = NetworkIO.ReceiveAsync(Outgoing, buffer, 0, buffer.Length, null, null, null);

            while (sent != buffer.Length)
            {
                int r = await Incoming.SendAsync(data, sent, data.Length - sent);

                Assert.AreNotEqual(0, r, "#Received data");
                sent += r;
            }

            Assert.IsTrue(task.Wait(TimeSpan.FromSeconds(10)), "Data should be all received");
            for (int i = 0; i < buffer.Length; i++)
            {
                if (data[i] != buffer[i])
                {
                    Assert.Fail("Buffers differ at position " + i);
                }
            }
        }