< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.HttpResponseMessageProperty
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/HttpResponseMessageProperty.cs
Line coverage
80%
Covered lines: 21
Uncovered lines: 5
Coverable lines: 26
Total lines: 108
Line coverage: 80.7%
Branch coverage
62%
Covered branches: 5
Total branches: 8
Branch coverage: 62.5%
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%
CoreWCF.Channels.IMessageProperty.CreateCopy()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/HttpResponseMessageProperty.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.Net;
 6
 7namespace CoreWCF.Channels
 8{
 9    public sealed class HttpResponseMessageProperty : IMessageProperty
 10    {
 11        public const HttpStatusCode DefaultStatusCode = HttpStatusCode.OK;
 12        public const string DefaultStatusDescription = null; // null means use description from status code
 13
 14        private WebHeaderCollection _originalHeaders;
 15        private HttpStatusCode _statusCode;
 16        private WebHeaderCollection _headers;
 17
 18        /// <summary>
 19        /// Initializes a new instance of the HttpResponseMessageProperty class with no headers and the default status c
 20        /// </summary>
 21        public HttpResponseMessageProperty()
 14322            : this((WebHeaderCollection)null)
 23        {
 14324        }
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="HttpResponseMessageProperty"/> class.
 28        /// </summary>
 29        /// <param name="originalHeaders">The original headers. This collection will be copied so that the original is n
 14330        internal HttpResponseMessageProperty(WebHeaderCollection originalHeaders)
 31        {
 14332            _originalHeaders = originalHeaders;
 14333            _statusCode = DefaultStatusCode;
 14334            StatusDescription = DefaultStatusDescription;
 14335        }
 36
 37        public const string Name = "httpResponse";
 38
 39        /// <summary>
 40        /// Gets a mutable list of headers.
 41        /// </summary>
 42        public WebHeaderCollection Headers
 43        {
 44            get
 45            {
 37846                if (_headers == null)
 47                {
 14348                    _headers = new WebHeaderCollection();
 14349                    if (_originalHeaders != null)
 50                    {
 051                        _headers.Add(_originalHeaders);
 052                        _originalHeaders = null;
 53                    }
 54                }
 55
 37856                return _headers;
 57            }
 58        }
 59
 60        /// <summary>
 61        /// Gets or sets the HTTP status code.
 62        /// </summary>
 63        /// <value>The HTTP status code.</value>
 64        /// <exception cref="ArgumentOutOfRangeException">The status code is less than 100 or greater than 599</exceptio
 65        public HttpStatusCode StatusCode
 66        {
 67            get
 68            {
 14769                return _statusCode;
 70            }
 71            set
 72            {
 11373                int valueInt = (int)value;
 11374                if (valueInt < 100 || valueInt > 599)
 75                {
 076                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentOutOfRangeException(nameof(val
 077                        SR.Format(SR.ValueMustBeInRange, 100, 599)));
 78                }
 79
 11380                _statusCode = value;
 11381                HasStatusCodeBeenSet = true;
 11382            }
 83        }
 84
 11385        internal bool HasStatusCodeBeenSet { get; private set; }
 86
 87        /// <summary>
 88        /// Gets or sets the HTTP status description.
 89        /// </summary>
 90        /// <value>The HTTP status description.</value>
 91        /// <remarks>If this returns null, use the default description for the current HttpStatusCode.</remarks>
 28892        public string StatusDescription { get; set; }
 93
 94        /// <summary>
 95        /// Gets or sets a value indicating whether to suppress entity body.
 96        /// </summary>
 97        /// <remarks>If this is true, then the content-type will not be set.</remarks>
 28598        public bool SuppressEntityBody { get; set; }
 99
 100        //Note currently in use. Remove?
 0101        public bool SuppressPreamble { get; set; }
 102
 103        IMessageProperty IMessageProperty.CreateCopy()
 104        {
 177105            return this;
 106        }
 107    }
 108}