public void ConnectWhenDisposed()
        {
            using (mocks.Ordered)
            {
                SetDisposeExpectations();
            }

            testTcpRemoteReceiver.Dispose();
            ObjectDisposedException e = Assert.Throws <ObjectDisposedException>(delegate
            {
                testTcpRemoteReceiver.Connect();
            });

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Пример #2
0
        //------------------------------------------------------------------------------
        //
        // Method: Disconnect
        //
        //------------------------------------------------------------------------------
        /// <summary>
        /// Disconnects and cleans up the underlying MethodInvocationRemoting components.
        /// </summary>
        public void Disconnect()
        {
            methodInvocationReceiver.CancelReceive();
            incomingReceiver.CancelReceive();
            incomingReceiver.Disconnect();
            incomingSender.Disconnect();
            outgoingReceiver.CancelReceive();
            outgoingReceiver.Disconnect();
            outgoingSender.Disconnect();

            // Call dispose on the sender and receiver objects
            incomingReceiver.Dispose();
            incomingSender.Dispose();
            outgoingReceiver.Dispose();
            outgoingSender.Dispose();
        }