Esempio n. 1
0
        public void DoSend(bool slowOutgoing, bool slowIncoming)
        {
            Incoming.SlowConnection = slowIncoming;
            Outgoing.SlowConnection = slowOutgoing;

            var task = NetworkIO.SendAsync(Outgoing, data, 0, data.Length, null, null, null);

            int received = 0;

            byte[] buffer = new byte[data.Length];
            while (received != buffer.Length)
            {
                int r = Incoming.Receive(buffer, received, buffer.Length - received);
                Assert.AreNotEqual(0, r, "#Received data");
                received += r;
            }
            Assert.IsTrue(task.Wait(TimeSpan.FromSeconds(1)), "Data should be all sent");
            Assert.IsTrue(Toolbox.ByteMatch(buffer, data), "Data matches");
        }
Esempio n. 2
0
        public void DoSend(bool slowOutgoing, bool slowIncoming)
        {
            Incoming.SlowConnection = slowIncoming;
            Outgoing.SlowConnection = slowOutgoing;

            var handle = new ManualResetEvent(false);

            NetworkIO.EnqueueSend(Outgoing, data, 0, data.Length, null, null, null, delegate {
                handle.Set();
            }, null);

            int received = 0;

            byte[] buffer = new byte [data.Length];
            while (received != buffer.Length)
            {
                int r = Incoming.Receive(buffer, received, buffer.Length - received);
                Assert.AreNotEqual(0, r, "#Received data");
                received += r;
            }
            Assert.IsTrue(handle.WaitOne(TimeSpan.FromSeconds(1)), "Data should be all sent");
            Assert.IsTrue(Toolbox.ByteMatch(buffer, data), "Data matches");
        }