< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.WebSocketTransportSettingsElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/WebSocketTransportSettingsElement.cs
Line coverage
46%
Covered lines: 14
Uncovered lines: 16
Coverable lines: 30
Total lines: 86
Line coverage: 46.6%
Branch coverage
33%
Covered branches: 2
Total branches: 6
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
InitializeFrom(...)0%220%
ApplyConfiguration(...)50%4488.88%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/WebSocketTransportSettingsElement.cs

#LineLine coverage
 1// Licensed to the .NET Foundation under one or more agreements.
 2// The .NET Foundation licenses this file to you under the MIT license.
 3
 4using System;
 5using System.Configuration;
 6using CoreWCF.Channels;
 7
 8namespace CoreWCF.Configuration
 9{
 10    public class WebSocketTransportSettingsElement : ServiceModelConfigurationElement
 11    {
 12        [ConfigurationProperty(ConfigurationStrings.TransportUsage, DefaultValue = WebSocketDefaults.TransportUsage)]
 13        public virtual WebSocketTransportUsage TransportUsage
 14        {
 415            get { return (WebSocketTransportUsage)base[ConfigurationStrings.TransportUsage]; }
 016            set { base[ConfigurationStrings.TransportUsage] = value; }
 17        }
 18
 19        [ConfigurationProperty(ConfigurationStrings.CreateNotificationOnConnection, DefaultValue = WebSocketDefaults.Cre
 20        public bool CreateNotificationOnConnection
 21        {
 422            get { return (bool)base[ConfigurationStrings.CreateNotificationOnConnection]; }
 023            set { base[ConfigurationStrings.CreateNotificationOnConnection] = value; }
 24        }
 25
 26        [ConfigurationProperty(ConfigurationStrings.KeepAliveInterval, DefaultValue = WebSocketDefaults.DefaultKeepAlive
 27        public TimeSpan KeepAliveInterval
 28        {
 429            get { return (TimeSpan)base[ConfigurationStrings.KeepAliveInterval]; }
 030            set { base[ConfigurationStrings.KeepAliveInterval] = value; }
 31        }
 32
 33        [ConfigurationProperty(ConfigurationStrings.SubProtocol, DefaultValue = null)]
 34        [StringValidator(MinLength = 0)]
 35        public virtual string SubProtocol
 36        {
 437            get { return (string)base[ConfigurationStrings.SubProtocol]; }
 038            set { base[ConfigurationStrings.SubProtocol] = value; }
 39        }
 40
 41        [ConfigurationProperty(ConfigurationStrings.DisablePayloadMasking, DefaultValue = WebSocketDefaults.DisablePaylo
 42        public bool DisablePayloadMasking
 43        {
 444            get { return (bool)base[ConfigurationStrings.DisablePayloadMasking]; }
 045            set { base[ConfigurationStrings.DisablePayloadMasking] = value; }
 46        }
 47
 48        [ConfigurationProperty(ConfigurationStrings.MaxPendingConnections, DefaultValue = WebSocketDefaults.DefaultMaxPe
 49        [IntegerValidator(MinValue = 0)]
 50        public int MaxPendingConnections
 51        {
 452            get { return (int)base[ConfigurationStrings.MaxPendingConnections]; }
 053            set { base[ConfigurationStrings.MaxPendingConnections] = value; }
 54        }
 55
 56        public void InitializeFrom(WebSocketTransportSettings settings)
 57        {
 058            if (settings == null)
 59            {
 060                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(settings));
 61            }
 62
 063            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.TransportUsage, settings.TransportUsage);
 064            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.CreateNotificationOnConnection, settings.CreateNotifi
 065            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.KeepAliveInterval, settings.KeepAliveInterval);
 066            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.SubProtocol, settings.SubProtocol);
 067            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.DisablePayloadMasking, settings.DisablePayloadMasking
 068            SetPropertyValueIfNotDefaultValue(ConfigurationStrings.MaxPendingConnections, settings.MaxPendingConnections
 069        }
 70
 71        public void ApplyConfiguration(WebSocketTransportSettings settings)
 72        {
 473            if (settings == null)
 74            {
 075                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(settings));
 76            }
 77
 478            settings.TransportUsage = TransportUsage;
 479            settings.CreateNotificationOnConnection = CreateNotificationOnConnection;
 480            settings.KeepAliveInterval = KeepAliveInterval;
 481            settings.SubProtocol = string.IsNullOrEmpty(SubProtocol) ? null : SubProtocol;
 482            settings.DisablePayloadMasking = DisablePayloadMasking;
 483            settings.MaxPendingConnections = MaxPendingConnections;
 484        }
 85    }
 86}