public ChannelWrapperTests(TaskClientConnector connector) : base(connector)
        {
            // init various things
            receiver = new SocketAsyncEventArgs();
            receiver.SetBuffer(receiveBuffer, 0, receiveBuffer.Length);
            receiverArgs = new DirectBytesReceivedEventArgs(receiver);

            sender = new SocketAsyncEventArgs();
            sender.SetBuffer(sendBuffer, 0, sendBuffer.Length);
            sendBufferWriter = new MemoryStream(sendBuffer, true);

            // establish a connection
            Task <Socket> task = connector.ConnectAsync();

            task.Wait(TimeSpan.FromSeconds(2));

            wrapper = new ChannelWrapperBase(task.Result, receiver, receiverArgs, sender, sendBufferWriter);

            WaitForServerConnections(1);

            // get the other end of the socket
            otherEnd = Connections[0];

            // set up event handlers
            wrapper.BytesReceived       += OnBytesReceived;
            wrapper.Closed              += OnClosed;
            wrapper.DuplexChannelClosed += OnDuplexChannelClosed;

            // start receive loop
            wrapper.Start();
        }
        public void AcceptsThruTask()
        {
            Task <Socket> task = connector.ConnectAsync();

            Assert.True(task.Wait(TimeSpan.FromSeconds(2)));

            Assert.NotNull(task.Result);

            Assert.Equal(1, OpenedConnections.Count);
            Assert.True(OpenedConnections[0].Connected);

            WaitForServerConnections(1);
            Assert.Equal(1, ConnectionCount);

            Assert.Throws <InvalidOperationException>(() => WaitForErrors(1));
        }