protected void Arrange() { var random = new Random(); _subsystemName = random.Next().ToString(CultureInfo.InvariantCulture); _operationTimeout = TimeSpan.FromSeconds(30); _encoding = Encoding.UTF8; _disconnectedRegister = new List<EventArgs>(); _errorOccurredRegister = new List<ExceptionEventArgs>(); _channelDataEventArgs = new ChannelDataEventArgs( (uint)random.Next(0, int.MaxValue), new[] { (byte)random.Next(byte.MinValue, byte.MaxValue) }); _sessionMock = new Mock<ISession>(MockBehavior.Strict); _channelMock = new Mock<IChannelSession>(MockBehavior.Strict); _sequence = new MockSequence(); _sessionMock.InSequence(_sequence).Setup(p => p.CreateChannelSession()).Returns(_channelMock.Object); _channelMock.InSequence(_sequence).Setup(p => p.Open()); _channelMock.InSequence(_sequence).Setup(p => p.SendSubsystemRequest(_subsystemName)).Returns(true); _subsystemSession = new SubsystemSessionStub( _sessionMock.Object, _subsystemName, _operationTimeout, _encoding); _subsystemSession.Disconnected += (sender, args) => _disconnectedRegister.Add(args); _subsystemSession.ErrorOccurred += (sender, args) => _errorOccurredRegister.Add(args); _subsystemSession.Connect(); }
private void Channel_DataReceived(object sender, Common.ChannelDataEventArgs e) { if (this._outputStream != null) { this._outputStream.Write(e.Data, 0, e.Data.Length); } }
private void Channel_ExtendedDataReceived(object sender, Common.ChannelDataEventArgs e) { if (this.ExtendedOutputStream != null) { this.ExtendedOutputStream.Write(e.Data, 0, e.Data.Length); this.ExtendedOutputStream.Flush(); } if (e.DataTypeCode == 1) { this._hasError = true; } }
private void Channel_DataReceived(object sender, Common.ChannelDataEventArgs e) { if (this.OutputStream != null) { this.OutputStream.Write(e.Data, 0, e.Data.Length); this.OutputStream.Flush(); } if (this._asyncResult != null) { lock (this._asyncResult) { this._asyncResult.BytesReceived += e.Data.Length; } } }
private void Channel_ExtendedDataReceived(object sender, ChannelDataEventArgs e) { if (this.ExtendedOutputStream != null) { this.ExtendedOutputStream.Write(e.Data, 0, e.Data.Length); this.ExtendedOutputStream.Flush(); } if (e.DataTypeCode == 1) { this._hasError = true; } }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { if (this.OutputStream != null) { this.OutputStream.Write(e.Data, 0, e.Data.Length); this.OutputStream.Flush(); } if (this._asyncResult != null) { lock (this._asyncResult) { this._asyncResult.BytesReceived += e.Data.Length; } } }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { lock (_incoming) { foreach (var b in e.Data) _incoming.Enqueue(b); } if (_dataReceived != null) _dataReceived.Set(); OnDataReceived(e.Data); }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { foreach (var b in e.Data) { _incoming.Enqueue(b); } this._dataReceived.Set(); this.OnDataReceived(e.Data); }
private void Channel_ExtendedDataReceived(object sender, ChannelDataEventArgs e) { if (this._extendedOutputStream != null) { this._extendedOutputStream.Write(e.Data, 0, e.Data.Length); } }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { try { OnDataReceived(e.DataTypeCode, e.Data); } catch (Exception ex) { RaiseError(ex); } }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { if (_outputStream != null) { _outputStream.Write(e.Data, 0, e.Data.Length); } }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { this.OnDataReceived(e.DataTypeCode, e.Data); }
private void Channel_DataReceived(object sender, ChannelDataEventArgs e) { lock (this._incoming) { foreach (var b in e.Data) { _incoming.Enqueue(b); } Monitor.Pulse(this._incoming); } this.OnDataReceived(e.Data); }