< Summary

Information
Class: Renci.SshNet.Sftp.Responses.SftpNameResponse
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Responses\SftpNameResponse.cs
Line coverage
100%
Covered lines: 40
Uncovered lines: 0
Coverable lines: 40
Total lines: 72
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
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_Count()100%1100%
get_Encoding()100%1100%
get_Files()100%1100%
.ctor(...)100%1100%
LoadData()100%4100%
SaveData()100%4100%
SupportsLongName(...)100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Responses\SftpNameResponse.cs

#LineLine coverage
 1using System;
 2using System.Collections.Generic;
 3using System.Text;
 4
 5namespace Renci.SshNet.Sftp.Responses
 6{
 7    internal sealed class SftpNameResponse : SftpResponse
 8    {
 9        public override SftpMessageTypes SftpMessageType
 10        {
 7211            get { return SftpMessageTypes.Name; }
 12        }
 13
 5663714        public uint Count { get; private set; }
 15
 5515116        public Encoding Encoding { get; private set; }
 17
 5677518        public KeyValuePair<string, SftpFileAttributes>[] Files { get; set; }
 19
 20        public SftpNameResponse(uint protocolVersion, Encoding encoding)
 1165121            : base(protocolVersion)
 1165122        {
 1165123            Files = Array.Empty<KeyValuePair<string, SftpFileAttributes>>();
 1165124            Encoding = encoding;
 1165125        }
 26
 27        protected override void LoadData()
 1163328        {
 1163329            base.LoadData();
 30
 1163331            Count = ReadUInt32();
 1163332            Files = new KeyValuePair<string, SftpFileAttributes>[Count];
 33
 6674234            for (var i = 0; i < Count; i++)
 2173835            {
 2173836                var fileName = ReadString(Encoding);
 2173837                if (SupportsLongName(ProtocolVersion))
 2173838                {
 2173839                    _ = ReadString(Encoding); // skip longname
 2173840                }
 41
 2173842                Files[i] = new KeyValuePair<string, SftpFileAttributes>(fileName, ReadAttributes());
 2173843            }
 1163344        }
 45
 46        protected override void SaveData()
 2447        {
 2448            base.SaveData();
 49
 2450            Write((uint) Files.Length); // count
 51
 9652            for (var i = 0; i < Files.Length; i++)
 2453            {
 2454                var file = Files[i];
 55
 2456                Write(file.Key, Encoding); // filename
 57
 2458                if (SupportsLongName(ProtocolVersion))
 2459                {
 2460                    Write(0U); // longname
 2461                }
 62
 2463                Write(file.Value.GetBytes()); // attrs
 2464            }
 2465        }
 66
 67        private static bool SupportsLongName(uint protocolVersion)
 2176268        {
 2176269            return protocolVersion <= 3U;
 2176270        }
 71    }
 72}