< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpLinkRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpLinkRequest.cs
Line coverage
81%
Covered lines: 27
Uncovered lines: 6
Coverable lines: 33
Total lines: 86
Line coverage: 81.8%
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_SftpMessageType()100%1100%
get_NewLinkPath()100%1100%
set_NewLinkPath(...)100%1100%
get_ExistingPath()100%1100%
set_ExistingPath(...)100%1100%
get_IsSymLink()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
LoadData()100%10%
SaveData()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpLinkRequest.cs

#LineLine coverage
 1using System;
 2
 3using Renci.SshNet.Sftp.Responses;
 4
 5namespace Renci.SshNet.Sftp.Requests
 6{
 7    internal sealed class SftpLinkRequest : SftpRequest
 8    {
 9        private byte[] _newLinkPath;
 10        private byte[] _existingPath;
 11
 12        public override SftpMessageTypes SftpMessageType
 13        {
 1814            get { return SftpMessageTypes.Link; }
 15        }
 16
 17        public string NewLinkPath
 18        {
 1819            get { return Utf8.GetString(_newLinkPath, 0, _newLinkPath.Length); }
 3620            private set { _newLinkPath = Utf8.GetBytes(value); }
 21        }
 22
 23        public string ExistingPath
 24        {
 1825            get { return Utf8.GetString(_existingPath, 0, _existingPath.Length); }
 3626            private set { _existingPath = Utf8.GetBytes(value); }
 27        }
 28
 2129        public bool IsSymLink { get; private set; }
 30
 31        /// <summary>
 32        /// Gets the size of the message in bytes.
 33        /// </summary>
 34        /// <value>
 35        /// The size of the messages in bytes.
 36        /// </value>
 37        protected override int BufferCapacity
 38        {
 39            get
 340            {
 341                var capacity = base.BufferCapacity;
 342                capacity += 4; // NewLinkPath length
 343                capacity += NewLinkPath.Length; // NewLinkPath
 344                capacity += 4; // ExistingPath length
 345                capacity += ExistingPath.Length; // ExistingPath
 346                capacity += 1; // IsSymLink
 347                return capacity;
 348            }
 49        }
 50
 51        /// <summary>
 52        /// Initializes a new instance of the <see cref="SftpLinkRequest" /> class.
 53        /// </summary>
 54        /// <param name="protocolVersion">The protocol version.</param>
 55        /// <param name="requestId">The request id.</param>
 56        /// <param name="newLinkPath">Specifies the path name of the new link to create.</param>
 57        /// <param name="existingPath">Specifies the path of a target object to which the newly created link will refer.
 58        /// <param name="isSymLink">if set to <see langword="false"/> the link should be a hard link, or a second direct
 59        /// <param name="statusAction">The status action.</param>
 60        public SftpLinkRequest(uint protocolVersion, uint requestId, string newLinkPath, string existingPath, bool isSym
 1261            : base(protocolVersion, requestId, statusAction)
 1262        {
 1263            NewLinkPath = newLinkPath;
 1264            ExistingPath = existingPath;
 1265            IsSymLink = isSymLink;
 1266        }
 67
 68        protected override void LoadData()
 069        {
 070            base.LoadData();
 71
 072            _newLinkPath = ReadBinary();
 073            _existingPath = ReadBinary();
 074            IsSymLink = ReadBoolean();
 075        }
 76
 77        protected override void SaveData()
 378        {
 379            base.SaveData();
 80
 381            WriteBinaryString(_newLinkPath);
 382            WriteBinaryString(_existingPath);
 383            Write(IsSymLink);
 384        }
 85    }
 86}