< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.WebBodyFormatMessageProperty
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Channels/WebBodyFormatMessageProperty.cs
Line coverage
88%
Covered lines: 15
Uncovered lines: 2
Coverable lines: 17
Total lines: 72
Line coverage: 88.2%
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(...)50%2280%
CreateCopy()100%11100%
ToString()100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Channels/WebBodyFormatMessageProperty.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;
 6
 7namespace CoreWCF.Channels
 8{
 9    public sealed class WebBodyFormatMessageProperty : IMessageProperty
 10    {
 11        public const string Name = "WebBodyFormatMessageProperty";
 12
 13        private static WebBodyFormatMessageProperty s_jsonProperty;
 14        private static WebBodyFormatMessageProperty s_xmlProperty;
 15        private static WebBodyFormatMessageProperty s_rawProperty;
 16
 317        public WebBodyFormatMessageProperty(WebContentFormat format)
 18        {
 319            if (format == WebContentFormat.Default)
 20            {
 021                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.DefaultCont
 22            }
 23
 324            Format = format;
 325        }
 26
 6427        public WebContentFormat Format { get; }
 28
 29        internal static WebBodyFormatMessageProperty JsonProperty
 30        {
 31            get
 32            {
 3033                if (s_jsonProperty == null)
 34                {
 135                    s_jsonProperty = new WebBodyFormatMessageProperty(WebContentFormat.Json);
 36                }
 37
 3038                return s_jsonProperty;
 39            }
 40        }
 41
 42        internal static WebBodyFormatMessageProperty XmlProperty
 43        {
 44            get
 45            {
 246                if (s_xmlProperty == null)
 47                {
 148                    s_xmlProperty = new WebBodyFormatMessageProperty(WebContentFormat.Xml);
 49                }
 50
 251                return s_xmlProperty;
 52            }
 53        }
 54
 55        internal static WebBodyFormatMessageProperty RawProperty
 56        {
 57            get
 58            {
 859                if (s_rawProperty == null)
 60                {
 161                    s_rawProperty = new WebBodyFormatMessageProperty(WebContentFormat.Raw);
 62                }
 63
 864                return s_rawProperty;
 65            }
 66        }
 67
 4068        public IMessageProperty CreateCopy() => this;
 69
 070        public override string ToString() => string.Format(CultureInfo.InvariantCulture, SR.Format(SR.WebBodyFormatPrope
 71    }
 72}