< Summary

Information
Class: Renci.SshNet.Messages.Connection.X11ChannelOpenInfo
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Connection\ChannelOpen\X11ChannelOpenInfo.cs
Line coverage
100%
Covered lines: 30
Uncovered lines: 0
Coverable lines: 30
Total lines: 104
Line coverage: 100%
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_ChannelType()100%1100%
get_OriginatorAddress()100%1100%
set_OriginatorAddress(...)100%1100%
get_OriginatorPort()100%1100%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
.ctor(...)100%1100%
LoadData()100%1100%
SaveData()100%1100%

File(s)

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

#LineLine coverage
 1using System;
 2
 3namespace Renci.SshNet.Messages.Connection
 4{
 5    /// <summary>
 6    /// Used to open "x11" channel type.
 7    /// </summary>
 8    internal sealed class X11ChannelOpenInfo : ChannelOpenInfo
 9    {
 10        private byte[] _originatorAddress;
 11
 12        /// <summary>
 13        /// Specifies channel open type.
 14        /// </summary>
 15        public const string Name = "x11";
 16
 17        /// <summary>
 18        /// Gets the type of the channel to open.
 19        /// </summary>
 20        /// <value>
 21        /// The type of the channel to open.
 22        /// </value>
 23        public override string ChannelType
 24        {
 3625            get { return Name; }
 26        }
 27
 28        /// <summary>
 29        /// Gets the originator address.
 30        /// </summary>
 31        public string OriginatorAddress
 32        {
 1833            get { return Utf8.GetString(_originatorAddress, 0, _originatorAddress.Length); }
 934            private set { _originatorAddress = Utf8.GetBytes(value); }
 35        }
 36
 37        /// <summary>
 38        /// Gets the originator port.
 39        /// </summary>
 1540        public uint OriginatorPort { get; private set; }
 41
 42        /// <summary>
 43        /// Gets the size of the message in bytes.
 44        /// </summary>
 45        /// <value>
 46        /// The size of the messages in bytes.
 47        /// </value>
 48        protected override int BufferCapacity
 49        {
 50            get
 351            {
 352                var capacity = base.BufferCapacity;
 353                capacity += 4; // OriginatorAddress length
 354                capacity += _originatorAddress.Length; // OriginatorAddress
 355                capacity += 4; // OriginatorPort
 356                return capacity;
 357            }
 58        }
 59
 60        /// <summary>
 61        /// Initializes a new instance of the <see cref="X11ChannelOpenInfo"/> class from the
 62        /// specified data.
 63        /// </summary>
 64        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <see langword="null"/>.</exception>
 365        public X11ChannelOpenInfo(byte[] data)
 366        {
 367            Load(data);
 368        }
 69
 70        /// <summary>
 71        /// Initializes a new instance of the <see cref="X11ChannelOpenInfo"/> class with the
 72        /// specified originator address and port.
 73        /// </summary>
 74        /// <param name="originatorAddress">The originator address.</param>
 75        /// <param name="originatorPort">The originator port.</param>
 376        public X11ChannelOpenInfo(string originatorAddress, uint originatorPort)
 377        {
 378            OriginatorAddress = originatorAddress;
 379            OriginatorPort = originatorPort;
 380        }
 81
 82        /// <summary>
 83        /// Called when type specific data need to be loaded.
 84        /// </summary>
 85        protected override void LoadData()
 386        {
 387            base.LoadData();
 88
 389            _originatorAddress = ReadBinary();
 390            OriginatorPort = ReadUInt32();
 391        }
 92
 93        /// <summary>
 94        /// Called when type specific data need to be saved.
 95        /// </summary>
 96        protected override void SaveData()
 397        {
 398            base.SaveData();
 99
 3100            WriteBinaryString(_originatorAddress);
 3101            Write(OriginatorPort);
 3102        }
 103    }
 104}