< Summary

Information
Class: Renci.SshNet.Messages.Connection.ExecRequestInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelRequest\ExecRequestInfo.cs
Line coverage
69%
Covered lines: 23
Uncovered lines: 10
Coverable lines: 33
Total lines: 117
Line coverage: 69.6%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_RequestName()100%1100%
get_Command()100%10%
get_Encoding()100%1100%
get_BufferCapacity()100%1100%
.ctor()100%1100%
.ctor(...)50%463.63%
LoadData()100%10%
SaveData()100%1100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Text;
 3
 4namespace Renci.SshNet.Messages.Connection
 5{
 6    /// <summary>
 7    /// Represents "exec" type channel request information.
 8    /// </summary>
 9    internal sealed class ExecRequestInfo : RequestInfo
 10    {
 11        private byte[] _command;
 12
 13        /// <summary>
 14        /// Channel request name.
 15        /// </summary>
 16        public const string Name = "exec";
 17
 18        /// <summary>
 19        /// Gets the name of the request.
 20        /// </summary>
 21        /// <value>
 22        /// The name of the request.
 23        /// </value>
 24        public override string RequestName
 25        {
 322526            get { return Name; }
 27        }
 28
 29        /// <summary>
 30        /// Gets command to execute.
 31        /// </summary>
 32        /// <value>
 33        /// The command.
 34        /// </value>
 35        public string Command
 36        {
 037            get { return Encoding.GetString(_command, 0, _command.Length); }
 38        }
 39
 40        /// <summary>
 41        /// Gets the encoding.
 42        /// </summary>
 43        /// <value>
 44        /// The encoding.
 45        /// </value>
 107546        public Encoding Encoding { get; private set; }
 47
 48        /// <summary>
 49        /// Gets the size of the message in bytes.
 50        /// </summary>
 51        /// <value>
 52        /// The size of the messages in bytes.
 53        /// </value>
 54        protected override int BufferCapacity
 55        {
 56            get
 107557            {
 107558                var capacity = base.BufferCapacity;
 107559                capacity += 4; // Command length
 107560                capacity += _command.Length; // Command
 107561                return capacity;
 107562            }
 63        }
 64
 65        /// <summary>
 66        /// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
 67        /// </summary>
 387968        public ExecRequestInfo()
 387969        {
 387970            WantReply = true;
 387971        }
 72
 73        /// <summary>
 74        /// Initializes a new instance of the <see cref="ExecRequestInfo"/> class.
 75        /// </summary>
 76        /// <param name="command">The command.</param>
 77        /// <param name="encoding">The character encoding to use.</param>
 78        /// <exception cref="ArgumentNullException"><paramref name="command"/> or <paramref name="encoding"/> is <see la
 79        public ExecRequestInfo(string command, Encoding encoding)
 107580            : this()
 107581        {
 107582            if (command is null)
 083            {
 084                throw new ArgumentNullException(nameof(command));
 85            }
 86
 107587            if (encoding is null)
 088            {
 089                throw new ArgumentNullException(nameof(encoding));
 90            }
 91
 107592            _command = encoding.GetBytes(command);
 107593            Encoding = encoding;
 107594        }
 95
 96        /// <summary>
 97        /// Called when type specific data need to be loaded.
 98        /// </summary>
 99        protected override void LoadData()
 0100        {
 0101            base.LoadData();
 102
 0103            _command = ReadBinary();
 0104            Encoding = Utf8;
 0105        }
 106
 107        /// <summary>
 108        /// Called when type specific data need to be saved.
 109        /// </summary>
 110        protected override void SaveData()
 1075111        {
 1075112            base.SaveData();
 113
 1075114            WriteBinaryString(_command);
 1075115        }
 116    }
 117}