< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.MessageVersion
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/MessageVersion.cs
Line coverage
55%
Covered lines: 33
Uncovered lines: 26
Coverable lines: 59
Total lines: 153
Line coverage: 55.9%
Branch coverage
44%
Covered branches: 15
Total branches: 34
Branch coverage: 44.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%
CreateVersion(...)100%11100%
CreateVersion(...)37.5%242434.48%
Equals(...)100%110%
GetHashCode()0%220%
ToString()100%11100%
IsMatch(...)50%8855.55%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Channels/MessageVersion.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.Globalization;
 6using CoreWCF.Runtime;
 7
 8namespace CoreWCF.Channels
 9{
 10    public sealed class MessageVersion
 11    {
 8412        private MessageVersion(EnvelopeVersion envelopeVersion, AddressingVersion addressingVersion)
 13        {
 8414            Envelope = envelopeVersion;
 8415            Addressing = addressingVersion;
 8416        }
 17
 22911518        public AddressingVersion Addressing { get; }
 22575319        public EnvelopeVersion Envelope { get; }
 20
 141221        public static MessageVersion Default => Soap12WSAddressing10;
 230222        public static MessageVersion None { get; } = new MessageVersion(EnvelopeVersion.None, AddressingVersion.None);
 74323        public static MessageVersion Soap11 { get; } = new MessageVersion(EnvelopeVersion.Soap11, AddressingVersion.None
 1724        public static MessageVersion Soap12 { get; } = new MessageVersion(EnvelopeVersion.Soap12, AddressingVersion.None
 1525        public static MessageVersion Soap11WSAddressing10 { get; } = new MessageVersion(EnvelopeVersion.Soap11, Addressi
 237126        public static MessageVersion Soap12WSAddressing10 { get; } = new MessageVersion(EnvelopeVersion.Soap12, Addressi
 1427        public static MessageVersion Soap11WSAddressingAugust2004 { get; } = new MessageVersion(EnvelopeVersion.Soap11, 
 5328        public static MessageVersion Soap12WSAddressingAugust2004 { get; } = new MessageVersion(EnvelopeVersion.Soap12, 
 29
 30        public static MessageVersion CreateVersion(EnvelopeVersion envelopeVersion)
 31        {
 44032            return CreateVersion(envelopeVersion, AddressingVersion.WSAddressing10);
 33        }
 34
 35        public static MessageVersion CreateVersion(EnvelopeVersion envelopeVersion, AddressingVersion addressingVersion)
 36        {
 57737            if (envelopeVersion == null)
 38            {
 039                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(envelopeVersion));
 40            }
 41
 57742            if (addressingVersion == null)
 43            {
 044                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(addressingVersion));
 45            }
 46
 57747            if (envelopeVersion == EnvelopeVersion.Soap12)
 48            {
 57649                if (addressingVersion == AddressingVersion.WSAddressing10)
 50                {
 56351                    return Soap12WSAddressing10;
 52                }
 1353                else if (addressingVersion == AddressingVersion.WSAddressingAugust2004)
 54                {
 1355                    return Soap12WSAddressingAugust2004;
 56                }
 057                else if (addressingVersion == AddressingVersion.None)
 58                {
 059                    return Soap12;
 60                }
 61                else
 62                {
 063                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(addressingVersion),
 064                        SR.Format(SR.AddressingVersionNotSupported, addressingVersion));
 65                }
 66            }
 167            else if (envelopeVersion == EnvelopeVersion.Soap11)
 68            {
 169                if (addressingVersion == AddressingVersion.WSAddressing10)
 70                {
 071                    return Soap11WSAddressing10;
 72                }
 173                else if (addressingVersion == AddressingVersion.WSAddressingAugust2004)
 74                {
 075                    return Soap11WSAddressingAugust2004;
 76                }
 177                else if (addressingVersion == AddressingVersion.None)
 78                {
 179                    return Soap11;
 80                }
 81                else
 82                {
 083                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(addressingVersion),
 084                        SR.Format(SR.AddressingVersionNotSupported, addressingVersion));
 85                }
 86            }
 087            else if (envelopeVersion == EnvelopeVersion.None)
 88            {
 089                if (addressingVersion == AddressingVersion.None)
 90                {
 091                    return None;
 92                }
 93                else
 94                {
 095                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(addressingVersion),
 096                        SR.Format(SR.AddressingVersionNotSupported, addressingVersion));
 97                }
 98            }
 99            else
 100            {
 0101                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(nameof(envelopeVersion),
 0102                    SR.Format(SR.EnvelopeVersionNotSupported, envelopeVersion));
 103            }
 104        }
 105
 106        public override bool Equals(object obj)
 107        {
 0108            return this == obj;
 109        }
 110
 111        public override int GetHashCode()
 112        {
 0113            int code = 0;
 0114            if (Envelope == EnvelopeVersion.Soap11)
 115            {
 0116                code += 1;
 117            }
 118
 0119            return code;
 120        }
 121
 122        public override string ToString()
 123        {
 34124            return SR.Format(SR.MessageVersionToStringFormat, Envelope.ToString(), Addressing.ToString());
 125        }
 126
 127        internal bool IsMatch(MessageVersion messageVersion)
 128        {
 1129            if (messageVersion == null)
 130            {
 131                Fx.Assert("Invalid (null) messageVersion value");
 0132                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(messageVersion));
 133            }
 1134            if (Addressing == null)
 135            {
 136                Fx.Assert("Invalid (null) addressing value");
 0137                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(string.Format(Cu
 138            }
 139
 1140            if (Envelope != messageVersion.Envelope)
 141            {
 0142                return false;
 143            }
 144
 1145            if (Addressing.Namespace != messageVersion.Addressing.Namespace)
 146            {
 0147                return false;
 148            }
 149
 1150            return true;
 151        }
 152    }
 153}