ChannelStub.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using Renci.SshNet.Channels;
  5. using Renci.SshNet.Messages.Connection;
  6. namespace Renci.SshNet.Tests.Classes.Channels
  7. {
  8. internal class ChannelStub : Channel
  9. {
  10. public override ChannelTypes ChannelType
  11. {
  12. get { return ChannelTypes.X11; }
  13. }
  14. public ChannelStub()
  15. {
  16. OnErrorOccurredInvocations = new List<Exception>();
  17. }
  18. public IList<Exception> OnErrorOccurredInvocations { get; private set; }
  19. public Exception OnCloseException { get; set; }
  20. public Exception OnDataException { get; set; }
  21. public Exception OnDisconnectedException { get; set; }
  22. public Exception OnEofException{ get; set; }
  23. public Exception OnErrorOccurredException { get; set; }
  24. public Exception OnExtendedDataException { get; set; }
  25. public Exception OnFailureException { get; set; }
  26. public Exception OnRequestException { get; set; }
  27. public Exception OnSuccessException { get; set; }
  28. public Exception OnWindowAdjustException { get; set; }
  29. public void SetIsOpen(bool value)
  30. {
  31. IsOpen = value;
  32. }
  33. public void InitializeRemoteChannelInfo(uint remoteChannelNumber, uint remoteWindowSize, uint remotePacketSize)
  34. {
  35. base.InitializeRemoteInfo(remoteChannelNumber, remoteWindowSize, remotePacketSize);
  36. }
  37. protected override void OnClose()
  38. {
  39. base.OnClose();
  40. if (OnCloseException != null)
  41. throw OnCloseException;
  42. }
  43. protected override void OnData(byte[] data)
  44. {
  45. base.OnData(data);
  46. if (OnDataException != null)
  47. throw OnDataException;
  48. }
  49. protected override void OnDisconnected()
  50. {
  51. base.OnDisconnected();
  52. if (OnDisconnectedException != null)
  53. throw OnDisconnectedException;
  54. }
  55. protected override void OnEof()
  56. {
  57. base.OnEof();
  58. if (OnEofException != null)
  59. throw OnEofException;
  60. }
  61. protected override void OnExtendedData(byte[] data, uint dataTypeCode)
  62. {
  63. base.OnExtendedData(data, dataTypeCode);
  64. if (OnExtendedDataException != null)
  65. throw OnExtendedDataException;
  66. }
  67. protected override void OnErrorOccured(Exception exp)
  68. {
  69. OnErrorOccurredInvocations.Add(exp);
  70. if (OnErrorOccurredException != null)
  71. throw OnErrorOccurredException;
  72. }
  73. protected override void OnFailure()
  74. {
  75. base.OnFailure();
  76. if (OnFailureException != null)
  77. throw OnFailureException;
  78. }
  79. protected override void OnRequest(RequestInfo info)
  80. {
  81. base.OnRequest(info);
  82. if (OnRequestException != null)
  83. throw OnRequestException;
  84. }
  85. protected override void OnSuccess()
  86. {
  87. base.OnSuccess();
  88. if (OnSuccessException != null)
  89. throw OnSuccessException;
  90. }
  91. protected override void OnWindowAdjust(uint bytesToAdd)
  92. {
  93. base.OnWindowAdjust(bytesToAdd);
  94. if (OnWindowAdjustException != null)
  95. throw OnWindowAdjustException;
  96. }
  97. }
  98. }