Exemplo n.º 1
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>();
            _initialSessionSemaphoreCount = random.Next(10, 20);
            _sessionSemaphore             = new SemaphoreLight(_initialSessionSemaphoreCount);

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

            _sequence = new MockSequence();
            _sessionMock.InSequence(_sequence).Setup(p => p.ConnectionInfo).Returns(_connectionInfoMock.Object);
            _connectionInfoMock.InSequence(_sequence).Setup(p => p.RetryAttempts).Returns(1);
            _sessionMock.Setup(p => p.SessionSemaphore).Returns(_sessionSemaphore);
            _sessionMock.InSequence(_sequence)
            .Setup(
                p =>
                p.SendMessage(
                    It.Is <ChannelOpenMessage>(
                        m =>
                        m.LocalChannelNumber == _localChannelNumber &&
                        m.InitialWindowSize == _localWindowSize && m.MaximumPacketSize == _localPacketSize &&
                        m.Info is SessionChannelOpenInfo)));
            _sessionMock.InSequence(_sequence)
            .Setup(p => p.WaitOnHandle(It.IsNotNull <WaitHandle>()))
            .Callback <WaitHandle>(
                w =>
            {
                _sessionMock.Raise(
                    s => s.ChannelOpenConfirmationReceived += null,
                    new MessageEventArgs <ChannelOpenConfirmationMessage>(
                        new ChannelOpenConfirmationMessage(
                            _localChannelNumber,
                            _remoteWindowSize,
                            _remotePacketSize,
                            _remoteChannelNumber)));
                w.WaitOne();
            });
            _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 ChannelSession(_sessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.Open();
        }
        protected override void Arrange()
        {
            base.Arrange();

            _channel            = new ChannelSession(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.Open();
        }
 protected override void Act()
 {
     try
     {
         _channel.Open();
     }
     catch (SshException ex)
     {
         _actualException = ex;
     }
 }
Exemplo n.º 4
0
 private void Act()
 {
     try
     {
         _channel.Open();
     }
     catch (SystemException ex)
     {
         _actualException = ex;
     }
 }
Exemplo n.º 5
0
        protected override void Arrange()
        {
            base.Arrange();

            _channel            = new ChannelSession(SessionMock.Object, _localChannelNumber, _localWindowSize, _localPacketSize);
            _channel.Closed    += (sender, args) => _channelClosedRegister.Add(args);
            _channel.Exception += (sender, args) => _channelExceptionRegister.Add(args);
            _channel.Open();

            SessionMock.Raise(
                p => p.ChannelCloseReceived += null,
                new MessageEventArgs <ChannelCloseMessage>(new ChannelCloseMessage(_localChannelNumber)));
        }
Exemplo n.º 6
0
 private void Act()
 {
     _channel.Open();
 }
Exemplo n.º 7
0
 protected override void Act()
 {
     _channel.Open();
 }