< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpOpenDirRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpOpenDirRequest.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\SftpOpenDirRequest.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 SftpOpenDirRequest : SftpRequest
 9    {
 10        private readonly Action<SftpHandleResponse> _handleAction;
 11        private byte[] _path;
 12
 13        public override SftpMessageTypes SftpMessageType
 14        {
 13215            get { return SftpMessageTypes.OpenDir; }
 16        }
 17
 18        public string Path
 19        {
 920            get { return Encoding.GetString(_path, 0, _path.Length); }
 15021            private set { _path = Encoding.GetBytes(value); }
 22        }
 23
 10624        public Encoding Encoding { get; private set; }
 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
 4135            {
 4136                var capacity = base.BufferCapacity;
 4137                capacity += 4; // Path length
 4138                capacity += _path.Length; // Path
 4139                return capacity;
 4140            }
 41        }
 42
 43        public SftpOpenDirRequest(uint protocolVersion, uint requestId, string path, Encoding encoding, Action<SftpHandl
 5044            : base(protocolVersion, requestId, statusAction)
 5045        {
 5046            Encoding = encoding;
 5047            Path = path;
 48
 5049            _handleAction = handleAction;
 5050        }
 51
 52        protected override void LoadData()
 053        {
 054            base.LoadData();
 55
 056            _path = ReadBinary();
 057        }
 58
 59        protected override void SaveData()
 4160        {
 4161            base.SaveData();
 62
 4163            WriteBinaryString(_path);
 4164        }
 65
 66        public override void Complete(SftpResponse response)
 4467        {
 4468            if (response is SftpHandleResponse handleResponse)
 3269            {
 3270                _handleAction(handleResponse);
 3271            }
 72            else
 1273            {
 1274                base.Complete(response);
 1275            }
 4476        }
 77    }
 78}