< Summary

Information
Class: Renci.SshNet.Messages.Connection.ChannelOpenFailureMessage
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpenFailureMessage.cs
Line coverage
63%
Covered lines: 26
Uncovered lines: 15
Coverable lines: 41
Total lines: 120
Line coverage: 63.4%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_ReasonCode()100%1100%
get_Description()100%1100%
set_Description(...)100%1100%
get_Language()100%1100%
set_Language(...)100%1100%
get_BufferCapacity()100%10%
.ctor()100%1100%
.ctor(...)100%1100%
.ctor(...)100%1100%
LoadData()100%1100%
SaveData()100%10%
Process(...)100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpenFailureMessage.cs

#LineLine coverage
 1namespace Renci.SshNet.Messages.Connection
 2{
 3    /// <summary>
 4    /// Represents SSH_MSG_CHANNEL_OPEN_FAILURE message.
 5    /// </summary>
 6    [Message("SSH_MSG_CHANNEL_OPEN_FAILURE", 92)]
 7    public class ChannelOpenFailureMessage : ChannelMessage
 8    {
 9        internal const uint AdministrativelyProhibited = 1;
 10        internal const uint ConnectFailed = 2;
 11        internal const uint UnknownChannelType = 3;
 12        internal const uint ResourceShortage = 4;
 13
 14        private byte[] _description;
 15        private byte[] _language;
 16
 17        /// <summary>
 18        /// Gets failure reason code.
 19        /// </summary>
 30320        public uint ReasonCode { get; private set; }
 21
 22        /// <summary>
 23        /// Gets description for failure.
 24        /// </summary>
 25        public string Description
 26        {
 41427            get { return Utf8.GetString(_description, 0, _description.Length); }
 32428            private set { _description = Utf8.GetBytes(value); }
 29        }
 30
 31        /// <summary>
 32        /// Gets message language.
 33        /// </summary>
 34        public string Language
 35        {
 41436            get { return Utf8.GetString(_language, 0, _language.Length); }
 32437            private set { _language = Utf8.GetBytes(value); }
 38        }
 39
 40        /// <summary>
 41        /// Gets the size of the message in bytes.
 42        /// </summary>
 43        /// <value>
 44        /// The size of the messages in bytes.
 45        /// </value>
 46        protected override int BufferCapacity
 47        {
 48            get
 049            {
 050                var capacity = base.BufferCapacity;
 051                capacity += 4; // ReasonCode
 052                capacity += 4; // Description length
 053                capacity += _description.Length; // Description
 054                capacity += 4; // Language length
 055                capacity += _language.Length; // Language
 056                return capacity;
 057            }
 58        }
 59
 60        /// <summary>
 61        /// Initializes a new instance of the <see cref="ChannelOpenFailureMessage"/> class.
 62        /// </summary>
 5763        public ChannelOpenFailureMessage()
 5764        {
 5765        }
 66
 67        /// <summary>
 68        /// Initializes a new instance of the <see cref="ChannelOpenFailureMessage"/> class.
 69        /// </summary>
 70        /// <param name="localChannelNumber">The local channel number.</param>
 71        /// <param name="description">The description.</param>
 72        /// <param name="reasonCode">The reason code.</param>
 73        public ChannelOpenFailureMessage(uint localChannelNumber, string description, uint reasonCode)
 8174            : this(localChannelNumber, description, reasonCode, "en")
 8175        {
 8176        }
 77
 78        /// <summary>
 79        /// Initializes a new instance of the <see cref="ChannelOpenFailureMessage"/> class.
 80        /// </summary>
 81        /// <param name="localChannelNumber">The local channel number.</param>
 82        /// <param name="description">The description.</param>
 83        /// <param name="reasonCode">The reason code.</param>
 84        /// <param name="language">The language (RFC3066).</param>
 85        public ChannelOpenFailureMessage(uint localChannelNumber, string description, uint reasonCode, string language)
 10886            : base(localChannelNumber)
 10887        {
 10888            Description = description;
 10889            ReasonCode = reasonCode;
 10890            Language = language;
 10891        }
 92
 93        /// <summary>
 94        /// Called when type specific data need to be loaded.
 95        /// </summary>
 96        protected override void LoadData()
 5797        {
 5798            base.LoadData();
 5799            ReasonCode = ReadUInt32();
 57100            _description = ReadBinary();
 57101            _language = ReadBinary();
 57102        }
 103
 104        /// <summary>
 105        /// Called when type specific data need to be saved.
 106        /// </summary>
 107        protected override void SaveData()
 0108        {
 0109            base.SaveData();
 0110            Write(ReasonCode);
 0111            WriteBinaryString(_description);
 0112            WriteBinaryString(_language);
 0113        }
 114
 115        internal override void Process(Session session)
 57116        {
 57117            session.OnChannelOpenFailureReceived(this);
 57118        }
 119    }
 120}