< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.SecurityTokenAttachmentModeHelper
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityTokenAttachmentMode.cs
Line coverage
73%
Covered lines: 19
Uncovered lines: 7
Coverable lines: 26
Total lines: 68
Line coverage: 73%
Branch coverage
69%
Covered branches: 9
Total branches: 13
Branch coverage: 69.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
IsDefined(...)83.33%66100%
Validate(...)50%2250%
Categorize(...)60%5572.22%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/SecurityTokenAttachmentMode.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.ComponentModel;
 6
 7namespace CoreWCF.Security
 8{
 9    public enum SecurityTokenAttachmentMode
 10    {
 11        Signed,
 12        Endorsing,
 13        SignedEndorsing,
 14        SignedEncrypted
 15    }
 16
 17    internal static class SecurityTokenAttachmentModeHelper
 18    {
 19        internal static bool IsDefined(SecurityTokenAttachmentMode value)
 20        {
 19221            return value == SecurityTokenAttachmentMode.Endorsing
 19222                || value == SecurityTokenAttachmentMode.Signed
 19223                || value == SecurityTokenAttachmentMode.SignedEncrypted
 19224                || value == SecurityTokenAttachmentMode.SignedEndorsing;
 25        }
 26
 27        internal static void Validate(SecurityTokenAttachmentMode value)
 28        {
 19229            if (!IsDefined(value))
 30            {
 031                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException(nameof(value)
 032                    typeof(SecurityTokenAttachmentMode)));
 33            }
 19234        }
 35
 36        internal static void Categorize(SecurityTokenAttachmentMode value,
 37            out bool isBasic, out bool isSignedButNotBasic, out ReceiveSecurityHeaderBindingModes mode)
 38        {
 6439            Validate(value);
 40
 41            switch (value)
 42            {
 43                case SecurityTokenAttachmentMode.Endorsing:
 2344                    isBasic = false;
 2345                    isSignedButNotBasic = false;
 2346                    mode = ReceiveSecurityHeaderBindingModes.Endorsing;
 2347                    break;
 48                case SecurityTokenAttachmentMode.Signed:
 2849                    isBasic = false;
 2850                    isSignedButNotBasic = true;
 2851                    mode = ReceiveSecurityHeaderBindingModes.Signed;
 2852                    break;
 53                case SecurityTokenAttachmentMode.SignedEncrypted:
 1354                    isBasic = true;
 1355                    isSignedButNotBasic = false;
 1356                    mode = ReceiveSecurityHeaderBindingModes.Basic;
 1357                    break;
 58                case SecurityTokenAttachmentMode.SignedEndorsing:
 059                    isBasic = false;
 060                    isSignedButNotBasic = true;
 061                    mode = ReceiveSecurityHeaderBindingModes.SignedEndorsing;
 062                    break;
 63                default:
 064                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 65            }
 66        }
 67    }
 68}