< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.FaultCode
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/FaultCode.cs
Line coverage
85%
Covered lines: 34
Uncovered lines: 6
Coverable lines: 40
Total lines: 132
Line coverage: 85%
Branch coverage
79%
Covered branches: 19
Total branches: 24
Branch coverage: 79.1%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)100%11100%
.ctor(...)66.66%121277.77%
CreateSenderFaultCode(...)100%11100%
CreateSenderFaultCode(...)100%11100%
CreateReceiverFaultCode(...)50%2266.66%
CreateReceiverFaultCode(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/FaultCode.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 CoreWCF.Description;
 6
 7namespace CoreWCF
 8{
 9    public class FaultCode
 10    {
 11        private readonly EnvelopeVersion _version;
 12
 13        public FaultCode(string name)
 25314            : this(name, "", null)
 15        {
 25316        }
 17
 18        public FaultCode(string name, FaultCode subCode)
 14619            : this(name, "", subCode)
 20        {
 14621        }
 22
 23        public FaultCode(string name, string ns)
 14824            : this(name, ns, null)
 25        {
 14826        }
 27
 54728        public FaultCode(string name, string ns, FaultCode subCode)
 29        {
 54730            if (name == null)
 31            {
 032                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(name));
 33            }
 34
 54735            if (name.Length == 0)
 36            {
 037                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(name)))
 38            }
 39
 54740            if (!string.IsNullOrEmpty(ns))
 41            {
 14842                NamingHelper.CheckUriParameter(ns, nameof(ns));
 43            }
 44
 54745            Name = name;
 54746            Namespace = ns;
 54747            SubCode = subCode;
 48
 54749            if (ns == Message12Strings.Namespace)
 50            {
 251                _version = EnvelopeVersion.Soap12;
 52            }
 54553            else if (ns == Message11Strings.Namespace)
 54            {
 055                _version = EnvelopeVersion.Soap11;
 56            }
 54557            else if (ns == MessageStrings.Namespace)
 58            {
 059                _version = EnvelopeVersion.None;
 60            }
 61            else
 62            {
 54563                _version = null;
 64            }
 54565        }
 66
 67        public bool IsPredefinedFault
 68        {
 69            get
 70            {
 100571                return Namespace.Length == 0 || _version != null;
 72            }
 73        }
 74
 75        public bool IsSenderFault
 76        {
 77            get
 78            {
 37379                if (IsPredefinedFault)
 80                {
 29781                    return Name == (_version ?? EnvelopeVersion.Soap12).SenderFaultName;
 82                }
 83
 7684                return false;
 85            }
 86        }
 87
 88        public bool IsReceiverFault
 89        {
 90            get
 91            {
 25992                if (IsPredefinedFault)
 93                {
 18394                    return Name == (_version ?? EnvelopeVersion.Soap12).ReceiverFaultName;
 95                }
 96
 7697                return false;
 98            }
 99        }
 100
 1081101        public string Namespace { get; }
 102
 740103        public string Name { get; }
 104
 449105        public FaultCode SubCode { get; }
 106
 107        public static FaultCode CreateSenderFaultCode(FaultCode subCode)
 108        {
 71109            return new FaultCode("Sender", subCode);
 110        }
 111
 112        public static FaultCode CreateSenderFaultCode(string name, string ns)
 113        {
 40114            return CreateSenderFaultCode(new FaultCode(name, ns));
 115        }
 116
 117        public static FaultCode CreateReceiverFaultCode(FaultCode subCode)
 118        {
 75119            if (subCode == null)
 120            {
 0121                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(subCode));
 122            }
 123
 75124            return new FaultCode("Receiver", subCode);
 125        }
 126
 127        public static FaultCode CreateReceiverFaultCode(string name, string ns)
 128        {
 0129            return CreateReceiverFaultCode(new FaultCode(name, ns));
 130        }
 131    }
 132}