< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.ServiceWebSocketContext
Assembly: CoreWCF.Http
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/ServiceWebSocketContext.cs
Line coverage
25%
Covered lines: 4
Uncovered lines: 12
Coverable lines: 16
Total lines: 86
Line coverage: 25%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Http/src/CoreWCF/Channels/ServiceWebSocketContext.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.Generic;
 6using System.Collections.Specialized;
 7using System.Net;
 8using System.Net.WebSockets;
 9using System.Security.Principal;
 10using CoreWCF.Runtime;
 11
 12namespace CoreWCF.Channels
 13{
 14    internal class ServiceWebSocketContext : WebSocketContext
 15    {
 16        private readonly WebSocketContext _context;
 17        private readonly IPrincipal _user;
 18
 1119        public ServiceWebSocketContext(WebSocketContext context, IPrincipal user)
 20        {
 21            Fx.Assert(context != null, "context should not be null.");
 1122            _context = context;
 1123            _user = user;
 1124        }
 25
 26        public override CookieCollection CookieCollection
 27        {
 028            get { return _context.CookieCollection; }
 29        }
 30
 31        public override NameValueCollection Headers
 32        {
 033            get { return _context.Headers; }
 34        }
 35
 36        public override bool IsAuthenticated
 37        {
 038            get { return _user != null ? _user.Identity != null && _user.Identity.IsAuthenticated : _context.IsAuthentic
 39        }
 40
 41        public override bool IsLocal
 42        {
 043            get { return _context.IsLocal; }
 44        }
 45
 46        public override bool IsSecureConnection
 47        {
 048            get { return _context.IsSecureConnection; }
 49        }
 50
 51        public override Uri RequestUri
 52        {
 053            get { return _context.RequestUri; }
 54        }
 55
 56        public override string SecWebSocketKey
 57        {
 058            get { return _context.SecWebSocketKey; }
 59        }
 60
 61        public override string Origin
 62        {
 063            get { return _context.Origin; }
 64        }
 65
 66        public override IEnumerable<string> SecWebSocketProtocols
 67        {
 068            get { return _context.SecWebSocketProtocols; }
 69        }
 70
 71        public override string SecWebSocketVersion
 72        {
 073            get { return _context.SecWebSocketVersion; }
 74        }
 75
 76        public override IPrincipal User
 77        {
 078            get { return _user ?? _context.User; }
 79        }
 80
 81        public override WebSocket WebSocket
 82        {
 083            get { throw Fx.Exception.AsError(new InvalidOperationException(SR.WebSocketContextWebSocketCannotBeAccessedE
 84        }
 85    }
 86}