< Summary

Information
Class: Renci.SshNet.Sftp.Requests.SftpWriteRequest
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Sftp\Requests\SftpWriteRequest.cs
Line coverage
78%
Covered lines: 29
Uncovered lines: 8
Coverable lines: 37
Total lines: 101
Line coverage: 78.3%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_SftpMessageType()100%1100%
get_Handle()100%1100%
get_ServerFileOffset()100%1100%
get_Data()100%1100%
get_Offset()100%1100%
get_Length()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
LoadData()100%10%
SaveData()100%1100%

File(s)

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

#LineLine coverage
 1using System;
 2using Renci.SshNet.Sftp.Responses;
 3
 4namespace Renci.SshNet.Sftp.Requests
 5{
 6    internal sealed class SftpWriteRequest : SftpRequest
 7    {
 8        public override SftpMessageTypes SftpMessageType
 9        {
 1180810            get { return SftpMessageTypes.Write; }
 11        }
 12
 1180813        public byte[] Handle { get; private set; }
 14
 15        /// <summary>
 16        /// Gets the zero-based offset (in bytes) relative to the beginning of the file that the write
 17        /// must start at.
 18        /// </summary>
 19        /// <value>
 20        /// The zero-based offset (in bytes) relative to the beginning of the file that the write must
 21        /// start at.
 22        /// </value>
 787523        public ulong ServerFileOffset { get; private set; }
 24
 25        /// <summary>
 26        /// Gets the buffer holding the data to write.
 27        /// </summary>
 28        /// <value>
 29        /// The buffer holding the data to write.
 30        /// </value>
 787531        public byte[] Data { get; private set; }
 32
 33        /// <summary>
 34        /// Gets the zero-based offset in <see cref="Data" /> at which to begin taking bytes to
 35        /// write.
 36        /// </summary>
 37        /// <value>
 38        /// The zero-based offset in <see cref="Data" /> at which to begin taking bytes to write.
 39        /// </value>
 787540        public int Offset { get; private set; }
 41
 42        /// <summary>
 43        /// Gets the length (in bytes) of the data to write.
 44        /// </summary>
 45        /// <value>
 46        /// The length (in bytes) of the data to write.
 47        /// </value>
 1180848        public int Length { get; private set; }
 49
 50        protected override int BufferCapacity
 51        {
 52            get
 393353            {
 393354                var capacity = base.BufferCapacity;
 393355                capacity += 4; // Handle length
 393356                capacity += Handle.Length; // Handle
 393357                capacity += 8; // ServerFileOffset length
 393358                capacity += 4; // Data length
 393359                capacity += Length; // Data
 393360                return capacity;
 393361            }
 62        }
 63
 64        public SftpWriteRequest(uint protocolVersion,
 65                                uint requestId,
 66                                byte[] handle,
 67                                ulong serverFileOffset,
 68                                byte[] data,
 69                                int offset,
 70                                int length,
 71                                Action<SftpStatusResponse> statusAction)
 393972            : base(protocolVersion, requestId, statusAction)
 393973        {
 393974            Handle = handle;
 393975            ServerFileOffset = serverFileOffset;
 393976            Data = data;
 393977            Offset = offset;
 393978            Length = length;
 393979        }
 80
 81        protected override void LoadData()
 082        {
 083            base.LoadData();
 84
 085            Handle = ReadBinary();
 086            ServerFileOffset = ReadUInt64();
 087            Data = ReadBinary();
 088            Offset = 0;
 089            Length = Data.Length;
 090        }
 91
 92        protected override void SaveData()
 393393        {
 393394            base.SaveData();
 95
 393396            WriteBinaryString(Handle);
 393397            Write(ServerFileOffset);
 393398            WriteBinary(Data, Offset, Length);
 393399        }
 100    }
 101}