< Summary

Information
Class: Renci.SshNet.Messages.Transport.ServiceRequestMessage
Assembly: Renci.SshNet
File(s): \home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Transport\ServiceRequestMessage.cs
Line coverage
68%
Covered lines: 13
Uncovered lines: 6
Coverable lines: 19
Total lines: 72
Line coverage: 68.4%
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_ServiceName()100%10%
get_BufferCapacity()100%1100%
.ctor(...)100%1100%
LoadData()100%10%
SaveData()100%1100%
Process(...)100%10%

File(s)

\home\appveyor\projects\ssh-net\src\Renci.SshNet\Messages\Transport\ServiceRequestMessage.cs

#LineLine coverage
 1using System;
 2using Renci.SshNet.Common;
 3
 4namespace Renci.SshNet.Messages.Transport
 5{
 6    /// <summary>
 7    /// Represents SSH_MSG_SERVICE_REQUEST message.
 8    /// </summary>
 9    [Message("SSH_MSG_SERVICE_REQUEST", 5)]
 10    public class ServiceRequestMessage : Message
 11    {
 12        private readonly byte[] _serviceName;
 13
 14        /// <summary>
 15        /// Gets the name of the service.
 16        /// </summary>
 17        /// <value>
 18        /// The name of the service.
 19        /// </value>
 20        public ServiceName ServiceName
 21        {
 022            get { return _serviceName.ToServiceName(); }
 23        }
 24
 25        /// <summary>
 26        /// Gets the size of the message in bytes.
 27        /// </summary>
 28        /// <value>
 29        /// The size of the messages in bytes.
 30        /// </value>
 31        protected override int BufferCapacity
 32        {
 33            get
 181334            {
 181335                var capacity = base.BufferCapacity;
 181336                capacity += 4; // ServiceName length
 181337                capacity += _serviceName.Length; // ServiceName
 181338                return capacity;
 181339            }
 40        }
 41
 42        /// <summary>
 43        /// Initializes a new instance of the <see cref="ServiceRequestMessage"/> class.
 44        /// </summary>
 45        /// <param name="serviceName">Name of the service.</param>
 181346        public ServiceRequestMessage(ServiceName serviceName)
 181347        {
 181348            _serviceName = serviceName.ToArray();
 181349        }
 50
 51        /// <summary>
 52        /// Called when type specific data need to be loaded.
 53        /// </summary>
 54        protected override void LoadData()
 055        {
 056            throw new InvalidOperationException("Load data is not supported.");
 57        }
 58
 59        /// <summary>
 60        /// Called when type specific data need to be saved.
 61        /// </summary>
 62        protected override void SaveData()
 181363        {
 181364            WriteBinaryString(_serviceName);
 181365        }
 66
 67        internal override void Process(Session session)
 068        {
 069            session.OnServiceRequestReceived(this);
 070        }
 71    }
 72}