< Summary

Information
Class: Renci.SshNet.Messages.Connection.EnvironmentVariableRequestInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelRequest\EnvironmentVariableRequestInfo.cs
Line coverage
13%
Covered lines: 4
Uncovered lines: 26
Coverable lines: 30
Total lines: 110
Line coverage: 13.3%
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_RequestName()100%10%
get_VariableName()100%10%
get_VariableValue()100%10%
get_BufferCapacity()100%10%
.ctor()100%1100%
.ctor(...)100%10%
LoadData()100%10%
SaveData()100%10%

File(s)

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

#LineLine coverage
 1namespace Renci.SshNet.Messages.Connection
 2{
 3    /// <summary>
 4    /// Represents "env" type channel request information.
 5    /// </summary>
 6    internal sealed class EnvironmentVariableRequestInfo : RequestInfo
 7    {
 8        private byte[] _variableName;
 9        private byte[] _variableValue;
 10
 11        /// <summary>
 12        /// Channel request name.
 13        /// </summary>
 14        public const string Name = "env";
 15
 16        /// <summary>
 17        /// Gets the name of the request.
 18        /// </summary>
 19        /// <value>
 20        /// The name of the request.
 21        /// </value>
 22        public override string RequestName
 23        {
 024            get { return Name; }
 25        }
 26
 27        /// <summary>
 28        /// Gets the name of the variable.
 29        /// </summary>
 30        /// <value>
 31        /// The name of the variable.
 32        /// </value>
 33        public string VariableName
 34        {
 035            get { return Utf8.GetString(_variableName, 0, _variableName.Length); }
 36        }
 37
 38        /// <summary>
 39        /// Gets the value of the variable.
 40        /// </summary>
 41        /// <value>
 42        /// The variable value.
 43        /// </value>
 44        public string VariableValue
 45        {
 046            get { return Utf8.GetString(_variableValue, 0, _variableValue.Length); }
 47        }
 48
 49        /// <summary>
 50        /// Gets the size of the message in bytes.
 51        /// </summary>
 52        /// <value>
 53        /// The size of the messages in bytes.
 54        /// </value>
 55        protected override int BufferCapacity
 56        {
 57            get
 058            {
 059                var capacity = base.BufferCapacity;
 060                capacity += 4; // VariableName length
 061                capacity += _variableName.Length; // VariableName
 062                capacity += 4; // VariableValue length
 063                capacity += _variableValue.Length; // VariableValue
 064                return capacity;
 065            }
 66        }
 67
 68        /// <summary>
 69        /// Initializes a new instance of the <see cref="EnvironmentVariableRequestInfo"/> class.
 70        /// </summary>
 280471        public EnvironmentVariableRequestInfo()
 280472        {
 280473            WantReply = true;
 280474        }
 75
 76        /// <summary>
 77        /// Initializes a new instance of the <see cref="EnvironmentVariableRequestInfo"/> class.
 78        /// </summary>
 79        /// <param name="variableName">Name of the variable.</param>
 80        /// <param name="variableValue">The variable value.</param>
 81        public EnvironmentVariableRequestInfo(string variableName, string variableValue)
 082            : this()
 083        {
 084            _variableName = Utf8.GetBytes(variableName);
 085            _variableValue = Utf8.GetBytes(variableValue);
 086        }
 87
 88        /// <summary>
 89        /// Called when type specific data need to be loaded.
 90        /// </summary>
 91        protected override void LoadData()
 092        {
 093            base.LoadData();
 94
 095            _variableName = ReadBinary();
 096            _variableValue = ReadBinary();
 097        }
 98
 99        /// <summary>
 100        /// Called when type specific data need to be saved.
 101        /// </summary>
 102        protected override void SaveData()
 0103        {
 0104            base.SaveData();
 105
 0106            WriteBinaryString(_variableName);
 0107            WriteBinaryString(_variableValue);
 0108        }
 109    }
 110}