< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.X509CertificateValidationModeHelper
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/X509CertificateValidationMode.cs
Line coverage
77%
Covered lines: 7
Uncovered lines: 2
Coverable lines: 9
Total lines: 59
Line coverage: 77.7%
Branch coverage
90%
Covered branches: 9
Total branches: 10
Branch coverage: 90%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
IsDefined(...)100%88100%
Validate(...)50%2250%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/X509CertificateValidationMode.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.ComponentModel;
 5
 6namespace CoreWCF.Security
 7{
 8    /// <summary>
 9    /// An enumeration that lists the ways of validating a certificate.
 10    /// </summary>
 11    public enum X509CertificateValidationMode
 12    {
 13        /// <summary>
 14        /// No validation of the certificate is performed.
 15        /// </summary>
 16        None,
 17
 18        /// <summary>
 19        /// The certificate is valid if it is in the trusted people store.
 20        /// </summary>
 21        PeerTrust,
 22
 23        /// <summary>
 24        /// The certificate is valid if the chain builds to a certification authority in the trusted root store.
 25        /// </summary>
 26        ChainTrust,
 27
 28        /// <summary>
 29        /// The certificate is valid if it is in the trusted people store, or if the chain builds to a certification aut
 30        /// </summary>
 31        PeerOrChainTrust,
 32
 33        /// <summary>
 34        /// The user must plug in a custom <c>X509CertificateValidator</c> to validate the certificate.
 35        /// </summary>
 36        Custom
 37    }
 38
 39    internal static class X509CertificateValidationModeHelper
 40    {
 41        public static bool IsDefined(X509CertificateValidationMode validationMode)
 42        {
 1043            return validationMode == X509CertificateValidationMode.None
 1044                || validationMode == X509CertificateValidationMode.PeerTrust
 1045                || validationMode == X509CertificateValidationMode.ChainTrust
 1046                || validationMode == X509CertificateValidationMode.PeerOrChainTrust
 1047                || validationMode == X509CertificateValidationMode.Custom;
 48        }
 49
 50        internal static void Validate(X509CertificateValidationMode value)
 51        {
 1052            if (!IsDefined(value))
 53            {
 054                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException(nameof(value)
 055                    typeof(X509CertificateValidationMode)));
 56            }
 1057        }
 58    }
 59}