Inheritance: Renci.SshNet.Channels.Channel
        private void Arrange()
        {
            var random = new Random();
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _localWindowSize = (uint)random.Next(0, int.MaxValue);
            _localPacketSize = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister = new List<ChannelEventArgs>();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            _sessionMock.Setup(p => p.IsConnected).Returns(true);
            _sessionMock.Setup(
                p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
                .Returns(true);

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            _sessionMock.Raise(p => p.ChannelEofReceived += null,
                new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
Ejemplo n.º 2
0
        private void Arrange()
        {
            var random = new Random();

            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _localWindowSize          = (uint)random.Next(0, int.MaxValue);
            _localPacketSize          = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber      = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize         = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize         = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister    = new List <ChannelEventArgs>();
            _channelExceptionRegister = new List <ExceptionEventArgs>();

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();

            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(
                p => p.TrySendMessage(It.Is <ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)))
            .Returns(true);
            _sessionMock.InSequence(sequence)
            .Setup(s => s.WaitOnHandle(It.IsNotNull <EventWaitHandle>()))
            .Callback <WaitHandle>(w => w.WaitOne());

            _channel            = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            _sessionMock.Raise(p => p.ChannelEofReceived += null,
                               new MessageEventArgs <ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
        private void Arrange()
        {
            var random = new Random();
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _localWindowSize = (uint)random.Next(0, int.MaxValue);
            _localPacketSize = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister = new List<ChannelEventArgs>();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();

            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
            _sessionMock.InSequence(sequence)
                .Setup(s => s.WaitOnHandle(It.IsNotNull<EventWaitHandle>()))
                .Callback<WaitHandle>(w => w.WaitOne());

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
        }
Ejemplo n.º 4
0
        protected override void Arrange()
        {
            base.Arrange();

            _channel            = new ChannelStub(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
        }
        protected override void Arrange()
        {
            base.Arrange();

            _channel = new ChannelStub(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.OnWindowAdjustException = _onWindowAdjustException;
        }
Ejemplo n.º 6
0
        private void Arrange()
        {
            var random = new Random();

            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _localWindowSize          = (uint)random.Next(0, int.MaxValue);
            _localPacketSize          = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber      = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize         = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize         = (uint)random.Next(0, int.MaxValue);
            _closeTimer               = new Stopwatch();
            _channelClosedWaitHandle  = new ManualResetEvent(false);
            _channelClosedRegister    = new List <ChannelEventArgs>();
            _channelExceptionRegister = new List <ExceptionEventArgs>();

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();

            _sessionMock.InSequence(sequence).Setup(p => p.SendMessage(It.Is <ChannelEofMessage>(c => c.LocalChannelNumber == _remoteChannelNumber)));
            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is <ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny <EventWaitHandle>()))
            .Callback <WaitHandle>(w =>
            {
                new Thread(() =>
                {
                    Thread.Sleep(100);
                    // raise ChannelCloseReceived event to set waithandle for receiving
                    // SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
                    // sending the SSH_MSG_CHANNEL_CLOSE message to the server
                    _sessionMock.Raise(s => s.ChannelCloseReceived += null,
                                       new MessageEventArgs <ChannelCloseMessage>(
                                           new ChannelCloseMessage(_localChannelNumber)));
                }).Start();
                _closeTimer.Start();
                try
                {
                    w.WaitOne();
                }
                finally
                {
                    _closeTimer.Stop();
                }
            });

            _channel         = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) =>
            {
                _channelClosedRegister.Add(args);
                _channelClosedWaitHandle.Set();
            };
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
            _channel.SendEof();
        }
        private void Arrange()
        {
            var random = new Random();
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _localWindowSize = (uint)random.Next(0, int.MaxValue);
            _localPacketSize = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
            _closeTimer = new Stopwatch();
            _channelClosedRegister = new List<ChannelEventArgs>();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();
            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
                .Callback<WaitHandle>(w =>
                    {
                        new Thread(() =>
                            {
                                Thread.Sleep(100);
                                // raise ChannelCloseReceived event to set waithandle for receiving
                                // SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
                                // sending the SSH_MSG_CHANNEL_CLOSE message to the server
                                _sessionMock.Raise(s => s.ChannelCloseReceived += null,
                                    new MessageEventArgs<ChannelCloseMessage>(
                                        new ChannelCloseMessage(_localChannelNumber)));
                            }).Start();
                        _closeTimer.Start();
                        try
                        {
                            w.WaitOne();
                        }
                        finally
                        {
                            _closeTimer.Stop();
                        }
                    });

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            _sessionMock.Raise(
                s => s.ChannelEofReceived += null,
                new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
        private void Arrange()
        {
            var random = new Random();

            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _localWindowSize          = (uint)random.Next(0, int.MaxValue);
            _localPacketSize          = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber      = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize         = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize         = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister    = new List <ChannelEventArgs>();
            _channelExceptionRegister = new List <ExceptionEventArgs>();
            _channelClosedReceived    = new ManualResetEvent(false);

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();

            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is <ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny <EventWaitHandle>()))
            .Callback <WaitHandle>(w =>
            {
                new Thread(() =>
                {
                    Thread.Sleep(100);
                    // signal that the ChannelCloseMessage was received; we use this to verify whether we've actually
                    // waited on the EventWaitHandle to be set
                    _channelClosedReceived.Set();
                    // raise ChannelCloseReceived event to set waithandle for receiving
                    // SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
                    // sending the SSH_MSG_CHANNEL_CLOSE message to the server
                    //
                    // we're mocking the wait on the ChannelCloseMessage, but we still want
                    // to get the channel in the state that it would have after actually receiving
                    // the ChannelCloseMessage
                    _sessionMock.Raise(s => s.ChannelCloseReceived += null, new MessageEventArgs <ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
                }).Start();
                w.WaitOne();
            });

            _channel            = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            _sessionMock.Raise(
                s => s.ChannelEofReceived += null,
                new MessageEventArgs <ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
        private void Arrange()
        {
            var random = new Random();
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _localWindowSize = (uint)random.Next(0, int.MaxValue);
            _localPacketSize = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister = new List<ChannelEventArgs>();
            _channelExceptionRegister = new List<ExceptionEventArgs>();
            _channelClosedReceived = new ManualResetEvent(false);

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            var sequence = new MockSequence();
            _sessionMock.InSequence(sequence).Setup(p => p.IsConnected).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.TrySendMessage(It.Is<ChannelCloseMessage>(c => c.LocalChannelNumber == _remoteChannelNumber))).Returns(true);
            _sessionMock.InSequence(sequence).Setup(p => p.WaitOnHandle(It.IsAny<EventWaitHandle>()))
                .Callback<WaitHandle>(w =>
                    {
                        new Thread(() =>
                            {
                                Thread.Sleep(100);
                                // signal that the ChannelCloseMessage was received; we use this to verify whether we've actually
                                // waited on the EventWaitHandle to be set
                                _channelClosedReceived.Set();
                                // raise ChannelCloseReceived event to set waithandle for receiving
                                // SSH_MSG_CHANNEL_CLOSE message from server which is waited on after
                                // sending the SSH_MSG_CHANNEL_CLOSE message to the server
                                // 
                                // we're mocking the wait on the ChannelCloseMessage, but we still want
                                // to get the channel in the state that it would have after actually receiving
                                // the ChannelCloseMessage
                                _sessionMock.Raise(s => s.ChannelCloseReceived += null, new MessageEventArgs<ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
                            }).Start();
                        w.WaitOne();
                    });

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            _sessionMock.Raise(
                s => s.ChannelEofReceived += null,
                new MessageEventArgs<ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
        private void Arrange()
        {
            var random = new Random();
            _localWindowSize = (uint) random.Next(1000, int.MaxValue);
            _localPacketSize = _localWindowSize - 1;
            _localChannelNumber = (uint) random.Next(0, int.MaxValue);
            _onCloseException = new SystemException();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.OnCloseException = _onCloseException;
        }
        protected override void Arrange()
        {
            base.Arrange();

            _channel         = new ChannelStub(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) =>
            {
                _channelClosedRegister.Add(args);
                Thread.Sleep(100);
                _channelClosedEventHandlerCompleted.Set();
            };
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
        }
        protected override void Arrange()
        {
            base.Arrange();

            _channel            = new ChannelStub(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => { _channelClosedRegister.Add(args); };
            _channel.EndOfData += (sender, args) => _channelEndOfDataRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);

            SessionMock.Raise(
                s => s.ChannelEofReceived += null,
                new MessageEventArgs <ChannelEofMessage>(new ChannelEofMessage(_localChannelNumber)));
        }
Ejemplo n.º 13
0
        private void Arrange()
        {
            var random = new Random();

            _localWindowSize          = (uint)random.Next(1000, int.MaxValue);
            _localPacketSize          = _localWindowSize - 1;
            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _onDataException          = new SystemException();
            _channelExceptionRegister = new List <ExceptionEventArgs>();

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            _channel                 = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception      += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.OnDataException = _onDataException;
        }
Ejemplo n.º 14
0
        private void Arrange()
        {
            var random = new Random();

            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _localWindowSize          = (uint)random.Next(0, int.MaxValue);
            _localPacketSize          = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister    = new List <ChannelEventArgs>();
            _channelExceptionRegister = new List <ExceptionEventArgs>();
            _actualException          = null;

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            _channel            = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
        }
        private void Arrange()
        {
            var random = new Random();
            _localWindowSize = (uint)random.Next(1000, int.MaxValue);
            _localPacketSize = _localWindowSize - 1;
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _onRequestException = new SystemException();
            _channelExceptionRegister = new List<ExceptionEventArgs>();
            _requestInfo = new SignalRequestInfo("ABC");

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);
            _sessionMock.Setup(p => p.ConnectionInfo)
                .Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.OnRequestException = _onRequestException;
        }
        private void Arrange()
        {
            var random = new Random();
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _localWindowSize = (uint)random.Next(0, int.MaxValue);
            _localPacketSize = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister = new List<ChannelEventArgs>();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            _sessionMock.Setup(p => p.IsConnected).Returns(false);

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.SetIsOpen(true);
        }
        private void Arrange()
        {
            var random = new Random();

            _localWindowSize          = (uint)random.Next(1000, int.MaxValue);
            _localPacketSize          = _localWindowSize - 1;
            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _onRequestException       = new SystemException();
            _channelExceptionRegister = new List <ExceptionEventArgs>();
            _requestInfo = new SignalRequestInfo("ABC");

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);
            _sessionMock.Setup(p => p.ConnectionInfo)
            .Returns(new ConnectionInfo("host", "user", new PasswordAuthenticationMethod("user", "password")));

            _channel                    = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception         += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.OnRequestException = _onRequestException;
        }
        private void Arrange()
        {
            var random = new Random();
            _localWindowSize = (uint)random.Next(0, 1000);
            _localPacketSize = (uint)random.Next(1001, int.MaxValue);
            _localChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize = (uint)random.Next(0, int.MaxValue);
            _onEofException = new SystemException();
            _channelExceptionRegister = new List<ExceptionEventArgs>();

            _sessionMock = new Mock<ISession>(MockBehavior.Strict);

            _channel = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
            _channel.OnEofException = _onEofException;
        }
        private void Arrange()
        {
            var random = new Random();

            _localWindowSize          = (uint)random.Next(0, 1000);
            _localPacketSize          = (uint)random.Next(1001, int.MaxValue);
            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber      = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize         = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize         = (uint)random.Next(0, int.MaxValue);
            _onEofException           = new SystemException();
            _channelExceptionRegister = new List <ExceptionEventArgs>();

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            _channel            = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
            _channel.OnEofException = _onEofException;
        }
        private void Arrange()
        {
            var random = new Random();

            _localChannelNumber       = (uint)random.Next(0, int.MaxValue);
            _localWindowSize          = (uint)random.Next(0, int.MaxValue);
            _localPacketSize          = (uint)random.Next(0, int.MaxValue);
            _remoteChannelNumber      = (uint)random.Next(0, int.MaxValue);
            _remoteWindowSize         = (uint)random.Next(0, int.MaxValue);
            _remotePacketSize         = (uint)random.Next(0, int.MaxValue);
            _channelClosedRegister    = new List <ChannelEventArgs>();
            _channelExceptionRegister = new List <ExceptionEventArgs>();

            _sessionMock = new Mock <ISession>(MockBehavior.Strict);

            _sessionMock.Setup(p => p.IsConnected).Returns(true);

            _channel            = new ChannelStub(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.InitializeRemoteChannelInfo(_remoteChannelNumber, _remoteWindowSize, _remotePacketSize);
            _channel.SetIsOpen(true);
        }