using System; using System.Collections.Generic; using System.Threading; using Renci.SshNet.Common; namespace Renci.SshNet.Tests.Classes { internal class SubsystemSessionStub : SubsystemSession { private int _onChannelOpenInvocationCount; public SubsystemSessionStub(ISession session, string subsystemName, int operationTimeout) : base(session, subsystemName, operationTimeout) { OnDataReceivedInvocations = new List(); } public int OnChannelOpenInvocationCount { get { return _onChannelOpenInvocationCount; } } public IList OnDataReceivedInvocations { get; private set; } public Exception OnChannelOpenException { get; set; } public Exception OnDataReceivedException { get; set; } protected override void OnChannelOpen() { _ = Interlocked.Increment(ref _onChannelOpenInvocationCount); if (OnChannelOpenException != null) { throw OnChannelOpenException; } } protected override void OnDataReceived(ArraySegment data) { OnDataReceivedInvocations.Add(new ChannelDataEventArgs(0, data)); if (OnDataReceivedException != null) { throw OnDataReceivedException; } } } }