< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpStatRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpStatRequest.cs
Line coverage
87%
Covered lines: 29
Uncovered lines: 4
Coverable lines: 33
Total lines: 76
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\SftpStatRequest.cs

#LineLine coverage
 1using System;
 2using System.Text;
 3using Renci.SshNet.Sftp.Responses;
 4
 5namespace Renci.SshNet.Sftp.Requests
 6{
 7    internal sealed class SftpStatRequest : SftpRequest
 8    {
 9        private readonly Action<SftpAttrsResponse> _attrsAction;
 10        private byte[] _path;
 11
 12        public override SftpMessageTypes SftpMessageType
 13        {
 1814            get { return SftpMessageTypes.Stat; }
 15        }
 16
 17        public string Path
 18        {
 919            get { return Encoding.GetString(_path, 0, _path.Length); }
 3620            private set { _path = Encoding.GetBytes(value); }
 21        }
 22
 1823        public Encoding Encoding { get; }
 24
 25        /// <summary>
 26        /// Gets the size of the message in bytes.
 27        /// </summary>
 28        /// <value>
 29        /// The size of the messages in bytes.
 30        /// </value>
 31        protected override int BufferCapacity
 32        {
 33            get
 334            {
 335                var capacity = base.BufferCapacity;
 336                capacity += 4; // Path length
 337                capacity += _path.Length; // Path
 338                return capacity;
 339            }
 40        }
 41
 42        public SftpStatRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action<SftpAttrsRes
 1243            : base(protocolVersion, requestId, statusAction)
 1244        {
 1245            Encoding = encoding;
 1246            Path = path;
 1247            _attrsAction = attrsAction;
 1248        }
 49
 50        protected override void LoadData()
 051        {
 052            base.LoadData();
 53
 054            _path = ReadBinary();
 055        }
 56
 57        protected override void SaveData()
 358        {
 359            base.SaveData();
 60
 361            WriteBinaryString(_path);
 362        }
 63
 64        public override void Complete(SftpResponse response)
 665        {
 666            if (response is SftpAttrsResponse attrsResponse)
 367            {
 368                _attrsAction(attrsResponse);
 369            }
 70            else
 371            {
 372                base.Complete(response);
 373            }
 674        }
 75    }
 76}