< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpReadLinkRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpReadLinkRequest.cs
Line coverage
87%
Covered lines: 29
Uncovered lines: 4
Coverable lines: 33
Total lines: 78
Line coverage: 87.8%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_SftpMessageType()100%1100%
get_Path()100%1100%
set_Path(...)100%1100%
get_Encoding()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
LoadData()100%10%
SaveData()100%1100%
Complete(...)100%2100%

File(s)

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

#LineLine coverage
 1using System;
 2using System.Text;
 3
 4using Renci.SshNet.Sftp.Responses;
 5
 6namespace Renci.SshNet.Sftp.Requests
 7{
 8    internal sealed class SftpReadLinkRequest : SftpRequest
 9    {
 10        private readonly Action<SftpNameResponse> _nameAction;
 11        private byte[] _path;
 12
 13        public override SftpMessageTypes SftpMessageType
 14        {
 1815            get { return SftpMessageTypes.ReadLink; }
 16        }
 17
 18        public string Path
 19        {
 920            get { return Encoding.GetString(_path, 0, _path.Length); }
 3621            private set { _path = Encoding.GetBytes(value); }
 22        }
 23
 1824        public Encoding Encoding { get; }
 25
 26        /// <summary>
 27        /// Gets the size of the message in bytes.
 28        /// </summary>
 29        /// <value>
 30        /// The size of the messages in bytes.
 31        /// </value>
 32        protected override int BufferCapacity
 33        {
 34            get
 335            {
 336                var capacity = base.BufferCapacity;
 337                capacity += 4; // Path length
 338                capacity += _path.Length; // Handle
 339                return capacity;
 340            }
 41        }
 42
 43        public SftpReadLinkRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action<SftpName
 1244            : base(protocolVersion, requestId, statusAction)
 1245        {
 1246            Encoding = encoding;
 1247            Path = path;
 48
 1249            _nameAction = nameAction;
 1250        }
 51
 52        protected override void LoadData()
 053        {
 054            base.LoadData();
 55
 056            _path = ReadBinary();
 057        }
 58
 59        protected override void SaveData()
 360        {
 361            base.SaveData();
 62
 363            WriteBinaryString(_path);
 364        }
 65
 66        public override void Complete(SftpResponse response)
 667        {
 668            if (response is SftpNameResponse nameResponse)
 369            {
 370                _nameAction(nameResponse);
 371            }
 72            else
 373            {
 374                base.Complete(response);
 375            }
 676        }
 77    }
 78}