< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.ExtendedProtectionPolicyElement
Assembly: CoreWCF.ConfigurationManager
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/ExtendedProtectionPolicyElement.cs
Line coverage
86%
Covered lines: 32
Uncovered lines: 5
Coverable lines: 37
Total lines: 116
Line coverage: 86.4%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%11100%
BuildPolicy()87.5%8890%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.ConfigurationManager/src/CoreWCF/Configuration/ExtendedProtectionPolicyElement.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.Collections.Generic;
 5using System.Configuration;
 6using System.Security.Authentication.ExtendedProtection;
 7
 8namespace CoreWCF.Configuration
 9{
 10    public sealed class ExtendedProtectionPolicyElement : ConfigurationElement
 11    {
 612        public ExtendedProtectionPolicyElement()
 13        {
 614            _properties.Add(_policyEnforcement);
 615            _properties.Add(_protectionScenario);
 616            _properties.Add(_customServiceNames);
 617        }
 18
 19        protected override ConfigurationPropertyCollection Properties
 20        {
 221            get { return _properties; }
 22        }
 23
 24        [ConfigurationProperty(ExtendedProtectionConfigurationStrings.PolicyEnforcement)]
 25        public PolicyEnforcement PolicyEnforcement
 26        {
 27            get
 28            {
 229                return (PolicyEnforcement)this[_policyEnforcement];
 30            }
 31            set
 32            {
 033                this[_policyEnforcement] = value;
 034            }
 35        }
 36
 37        [ConfigurationProperty(ExtendedProtectionConfigurationStrings.ProtectionScenario, DefaultValue = ProtectionScena
 38        public ProtectionScenario ProtectionScenario
 39        {
 40            get
 41            {
 142                return (ProtectionScenario)this[_protectionScenario];
 43            }
 44            set
 45            {
 046                this[_protectionScenario] = value;
 047            }
 48        }
 49
 50        [ConfigurationProperty(ExtendedProtectionConfigurationStrings.CustomServiceNames)]
 51        public ServiceNameElementCollection CustomServiceNames
 52        {
 53            get
 54            {
 155                return (ServiceNameElementCollection)this[_customServiceNames];
 56            }
 57        }
 58
 59        public ExtendedProtectionPolicy BuildPolicy()
 60        {
 161            if (PolicyEnforcement == PolicyEnforcement.Never)
 62            {
 063                return new ExtendedProtectionPolicy(PolicyEnforcement.Never);
 64            }
 65
 166            ServiceNameCollection spns = null;
 67
 168            ServiceNameElementCollection spnCollection = CustomServiceNames;
 169            if (spnCollection != null && spnCollection.Count > 0)
 70            {
 171                List<string> spnList = new List<string>(spnCollection.Count);
 472                foreach (ServiceNameElement element in spnCollection)
 73                {
 174                    spnList.Add(element.Name);
 75                }
 176                spns = new ServiceNameCollection(spnList);
 77            }
 78
 179            return new ExtendedProtectionPolicy(PolicyEnforcement, ProtectionScenario, spns);
 80        }
 81
 682        private readonly ConfigurationPropertyCollection _properties = new ConfigurationPropertyCollection();
 83
 84        private static PolicyEnforcement DefaultPolicyEnforcement
 85        {
 86            get
 87            {
 688                return PolicyEnforcement.Never;
 89            }
 90        }
 91
 692        private readonly ConfigurationProperty _policyEnforcement =
 693            new ConfigurationProperty(ExtendedProtectionConfigurationStrings.PolicyEnforcement,
 694                typeof(PolicyEnforcement), DefaultPolicyEnforcement,
 695                ConfigurationPropertyOptions.None);
 96
 697        private readonly ConfigurationProperty _protectionScenario =
 698            new ConfigurationProperty(ExtendedProtectionConfigurationStrings.ProtectionScenario,
 699                typeof(ProtectionScenario), ProtectionScenario.TransportSelected,
 6100                ConfigurationPropertyOptions.None);
 101
 6102        private readonly ConfigurationProperty _customServiceNames =
 6103            new ConfigurationProperty(ExtendedProtectionConfigurationStrings.CustomServiceNames,
 6104                typeof(ServiceNameElementCollection), null,
 6105                ConfigurationPropertyOptions.None);
 106    }
 107
 108    internal static class ExtendedProtectionConfigurationStrings
 109    {
 110        internal const string ExtendedProtectionPolicy = "extendedProtectionPolicy";
 111        internal const string PolicyEnforcement = "policyEnforcement";
 112        internal const string ProtectionScenario = "protectionScenario";
 113        internal const string CustomServiceNames = "customServiceNames";
 114        internal const string Name = "name";
 115    }
 116}