< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpOpenRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpOpenRequest.cs
Line coverage
90%
Covered lines: 40
Uncovered lines: 4
Coverable lines: 44
Total lines: 96
Line coverage: 90.9%
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_Filename()100%1100%
set_Filename(...)100%1100%
get_Flags()100%1100%
get_Attributes()100%10%
set_Attributes(...)100%1100%
get_Encoding()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)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\SftpOpenRequest.cs

#LineLine coverage
 1using System;
 2using System.Text;
 3using Renci.SshNet.Sftp.Responses;
 4
 5namespace Renci.SshNet.Sftp.Requests
 6{
 7    internal sealed class SftpOpenRequest : SftpRequest
 8    {
 9        private readonly Action<SftpHandleResponse> _handleAction;
 10        private byte[] _fileName;
 11        private byte[] _attributes;
 12
 13        public override SftpMessageTypes SftpMessageType
 14        {
 130515            get { return SftpMessageTypes.Open; }
 16        }
 17
 18        public string Filename
 19        {
 920            get { return Encoding.GetString(_fileName, 0, _fileName.Length); }
 132321            private set { _fileName = Encoding.GetBytes(value); }
 22        }
 23
 43224        public Flags Flags { get; }
 25
 26        public SftpFileAttributes Attributes
 27        {
 028            get { return SftpFileAttributes.FromBytes(_attributes); }
 132329            private set { _attributes = value.GetBytes(); }
 30        }
 31
 44732        public Encoding Encoding { get; }
 33
 34        /// <summary>
 35        /// Gets the size of the message in bytes.
 36        /// </summary>
 37        /// <value>
 38        /// The size of the messages in bytes.
 39        /// </value>
 40        protected override int BufferCapacity
 41        {
 42            get
 43243            {
 43244                var capacity = base.BufferCapacity;
 43245                capacity += 4; // FileName length
 43246                capacity += _fileName.Length; // FileName
 43247                capacity += 4; // Flags
 43248                capacity += _attributes.Length; // Attributes
 43249                return capacity;
 43250            }
 51        }
 52
 53        public SftpOpenRequest(uint protocolVersion, uint requestId, string fileName, Encoding encoding, Flags flags, Ac
 44154            : this(protocolVersion, requestId, fileName, encoding, flags, SftpFileAttributes.Empty, handleAction, status
 44155        {
 44156        }
 57
 58        private SftpOpenRequest(uint protocolVersion, uint requestId, string fileName, Encoding encoding, Flags flags, S
 44159            : base(protocolVersion, requestId, statusAction)
 44160        {
 44161            Encoding = encoding;
 44162            Filename = fileName;
 44163            Flags = flags;
 44164            Attributes = attributes;
 65
 44166            _handleAction = handleAction;
 44167        }
 68
 69        protected override void LoadData()
 070        {
 071            base.LoadData();
 072            throw new NotSupportedException();
 73        }
 74
 75        protected override void SaveData()
 43276        {
 43277            base.SaveData();
 78
 43279            WriteBinaryString(_fileName);
 43280            Write((uint) Flags);
 43281            Write(_attributes);
 43282        }
 83
 84        public override void Complete(SftpResponse response)
 42385        {
 42386            if (response is SftpHandleResponse handleResponse)
 37687            {
 37688                _handleAction(handleResponse);
 37689            }
 90            else
 4791            {
 4792                base.Complete(response);
 4793            }
 42394        }
 95    }
 96}