< Summary

Information
Class: Renci.SshNet.Messages.Connection.ChannelDataMessage
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelDataMessage.cs
Line coverage
100%
Covered lines: 43
Uncovered lines: 0
Coverable lines: 43
Total lines: 129
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_Data()100%1100%
get_Offset()100%1100%
get_Size()100%1100%
get_BufferCapacity()100%1100%
Process(...)100%1100%
.ctor()100%1100%
.ctor(...)100%2100%
.ctor(...)100%2100%
LoadData()100%1100%
SaveData()100%1100%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelDataMessage.cs

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Messages.Connection
 4{
 5    /// <summary>
 6    /// Represents SSH_MSG_CHANNEL_DATA message.
 7    /// </summary>
 8    [Message("SSH_MSG_CHANNEL_DATA", MessageNumber)]
 9    public class ChannelDataMessage : ChannelMessage
 10    {
 11        internal const byte MessageNumber = 94;
 12
 13        /// <summary>
 14        /// Gets the message data.
 15        /// </summary>
 16        /// <value>
 17        /// The data.
 18        /// </value>
 19        /// <remarks>
 20        /// The actual data to read or write depends on the <see cref="Offset"/> and <see cref="Size"/>.
 21        /// </remarks>
 17813422        public byte[] Data { get; private set; }
 23
 24        /// <summary>
 25        /// Gets the zero-based offset in <see cref="Data"/> at which the data begins.
 26        /// </summary>
 27        /// <value>
 28        /// The zero-based offset in <see cref="Data"/> at which the data begins.
 29        /// </value>
 10861730        public int Offset { get; private set; }
 31
 32        /// <summary>
 33        /// Gets the number of bytes of <see cref="Data"/> to read or write.
 34        /// </summary>
 35        /// <value>
 36        /// The number of bytes of <see cref="Data"/> to read or write.
 37        /// </value>
 14553438        public int Size { get; private set; }
 39
 40        /// <summary>
 41        /// Gets the size of the message in bytes.
 42        /// </summary>
 43        /// <value>
 44        /// The size of the messages in bytes.
 45        /// </value>
 46        protected override int BufferCapacity
 47        {
 48            get
 3691749            {
 3691750                var capacity = base.BufferCapacity;
 3691751                capacity += 4; // Data length
 3691752                capacity += Size; // Data
 3691753                return capacity;
 3691754            }
 55        }
 56
 57        internal override void Process(Session session)
 3475458        {
 3475459            session.OnChannelDataReceived(this);
 3475460        }
 61
 62        /// <summary>
 63        /// Initializes a new instance of the <see cref="ChannelDataMessage"/> class.
 64        /// </summary>
 3476065        public ChannelDataMessage()
 3476066        {
 3476067        }
 68
 69        /// <summary>
 70        /// Initializes a new instance of the <see cref="ChannelDataMessage"/> class.
 71        /// </summary>
 72        /// <param name="localChannelNumber">The local channel number.</param>
 73        /// <param name="data">Message data.</param>
 74        public ChannelDataMessage(uint localChannelNumber, byte[] data)
 1275            : base(localChannelNumber)
 1276        {
 1277            if (data is null)
 378            {
 379                throw new ArgumentNullException(nameof(data));
 80            }
 81
 982            Data = data;
 983            Offset = 0;
 984            Size = data.Length;
 985        }
 86
 87        /// <summary>
 88        /// Initializes a new instance of the <see cref="ChannelDataMessage"/> class.
 89        /// </summary>
 90        /// <param name="localChannelNumber">The local channel number.</param>
 91        /// <param name="data">The message data.</param>
 92        /// <param name="offset">The zero-based byte offset in <paramref name="data"/> at which to begin reading or writ
 93        /// <param name="size">The number of bytes of <paramref name="data"/> to read or write.</param>
 94        public ChannelDataMessage(uint localChannelNumber, byte[] data, int offset, int size)
 3692595            : base(localChannelNumber)
 3692596        {
 3692597            if (data is null)
 398            {
 399                throw new ArgumentNullException(nameof(data));
 100            }
 101
 36922102            Data = data;
 36922103            Offset = offset;
 36922104            Size = size;
 36922105        }
 106
 107        /// <summary>
 108        /// Loads the data.
 109        /// </summary>
 110        protected override void LoadData()
 34757111        {
 34757112            base.LoadData();
 113
 34757114            Data = ReadBinary();
 34757115            Offset = 0;
 34757116            Size = Data.Length;
 34757117        }
 118
 119        /// <summary>
 120        /// Saves the data.
 121        /// </summary>
 122        protected override void SaveData()
 36917123        {
 36917124            base.SaveData();
 125
 36917126            WriteBinary(Data, Offset, Size);
 36917127        }
 128    }
 129}