< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.WebSocketMessageProperty
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/WebSocketMessageProperty.cs
Line coverage
42%
Covered lines: 11
Uncovered lines: 15
Coverable lines: 26
Total lines: 82
Line coverage: 42.3%
Branch coverage
33%
Covered branches: 2
Total branches: 6
Branch coverage: 33.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor()100%110%
.ctor(...)100%11100%
TryGet(...)50%4457.14%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/WebSocketMessageProperty.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.Collections.ObjectModel;
 6using System.Net.Http;
 7using System.Net.WebSockets;
 8using CoreWCF.Runtime;
 9
 10namespace CoreWCF.Channels
 11{
 12    public sealed class WebSocketMessageProperty
 13    {
 14        public const string Name = "WebSocketMessageProperty";
 15        private readonly ReadOnlyDictionary<string, object> _properties;
 16
 17        /// <summary>
 18        /// Initializes a new instance of the WebSocketMessageProperty class.
 19        /// </summary>
 20        /// <remarks>Defaults: WebSocketMessageType.Binary</remarks>
 021        public WebSocketMessageProperty()
 22        {
 023            MessageType = WebSocketDefaults.DefaultWebSocketMessageType;
 024        }
 25
 1626        internal WebSocketMessageProperty(WebSocketContext context, string subProtocol, WebSocketMessageType incomingMes
 27        {
 1628            WebSocketContext = context;
 1629            SubProtocol = subProtocol;
 1630            MessageType = incomingMessageType;
 1631            _properties = properties;
 1632        }
 33
 34        /// <summary>
 35        /// Gets the web socket context.
 36        /// </summary>
 037        public WebSocketContext WebSocketContext { get; }
 38
 39        /// <summary>
 40        /// Gets the sub-protocol.
 41        /// </summary>
 042        public string SubProtocol { get; }
 43
 44        /// <summary>
 45        /// Gets or sets the type of the message. The default is WebSocketMessageType.Binary.
 46        /// </summary>
 1647        public WebSocketMessageType MessageType { get; set; }
 48
 49        public ReadOnlyDictionary<string, object> OpeningHandshakeProperties
 50        {
 51            get
 52            {
 053                if (_properties == null)
 54                {
 055                    throw Fx.Exception.AsError(new InvalidOperationException(SR.Format(
 056                        SR.WebSocketOpeningHandshakePropertiesNotAvailable,
 057                        "RequestMessage",
 058                        typeof(HttpResponseMessage).Name,
 059                        typeof(DelegatingHandler).Name)));
 60                }
 61
 062                return _properties;
 63            }
 64        }
 65
 66        internal static bool TryGet(MessageProperties properties, out WebSocketMessageProperty property)
 67        {
 1568            if (properties == null)
 69            {
 070                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(properties));
 71            }
 72
 1573            property = null;
 1574            if (properties.TryGetValue(Name, out object foundProperty))
 75            {
 076                property = (WebSocketMessageProperty)foundProperty;
 077                return true;
 78            }
 1579            return false;
 80        }
 81    }
 82}