< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.WrapperSecurityCommunicationObject
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrapperSecurityCommunicationObject.cs
Line coverage
60%
Covered lines: 9
Uncovered lines: 6
Coverable lines: 15
Total lines: 176
Line coverage: 60%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%22100%
GetCommunicationObjectType()100%110%
OnAbort()100%110%
OnFaulted()100%110%
ThrowIfDisposedOrImmutable()100%11100%
OnCloseAsync(...)100%11100%
OnOpenAsync(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/WrapperSecurityCommunicationObject.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.Threading;
 6using System.Threading.Tasks;
 7using CoreWCF.Channels;
 8using CoreWCF.IdentityModel.Selectors;
 9
 10namespace CoreWCF.Security
 11{
 12    internal class WrapperSecurityCommunicationObject : CommunicationObject
 13    {
 14        private readonly ISecurityCommunicationObject _innerCommunicationObject;
 15
 13416        public WrapperSecurityCommunicationObject(ISecurityCommunicationObject innerCommunicationObject) : base()
 17        {
 13418            _innerCommunicationObject = innerCommunicationObject ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelper
 13419        }
 20
 21        protected override Type GetCommunicationObjectType()
 22        {
 023            return _innerCommunicationObject.GetType();
 24        }
 25
 2026        protected override TimeSpan DefaultCloseTimeout => _innerCommunicationObject.DefaultCloseTimeout;
 27
 22228        protected override TimeSpan DefaultOpenTimeout => _innerCommunicationObject.DefaultOpenTimeout;
 29
 30        protected override void OnAbort()
 31        {
 032            _innerCommunicationObject.OnAbort();
 033        }
 34
 35        protected override void OnFaulted()
 36        {
 037            _innerCommunicationObject.OnFaulted();
 038            base.OnFaulted();
 039        }
 40
 41        internal new void ThrowIfDisposedOrImmutable()
 42        {
 141443            base.ThrowIfDisposedOrImmutable();
 141444        }
 45
 46        protected override Task OnCloseAsync(CancellationToken token)
 47        {
 1048            return _innerCommunicationObject.OnCloseAsync(DefaultCloseTimeout);
 49        }
 50
 51        protected override Task OnOpenAsync(CancellationToken token)
 52        {
 11153            return _innerCommunicationObject.OnOpenAsync(DefaultOpenTimeout);
 54        }
 55    }
 56
 57    internal abstract class CommunicationObjectSecurityTokenAuthenticator : SecurityTokenAuthenticator, ICommunicationOb
 58    {
 59        protected CommunicationObjectSecurityTokenAuthenticator()
 60        {
 61            CommunicationObject = new WrapperSecurityCommunicationObject(this);
 62        }
 63
 64        protected WrapperSecurityCommunicationObject CommunicationObject { get; }
 65
 66        public event EventHandler Closed
 67        {
 68            add { CommunicationObject.Closed += value; }
 69            remove { CommunicationObject.Closed -= value; }
 70        }
 71
 72        public event EventHandler Closing
 73        {
 74            add { CommunicationObject.Closing += value; }
 75            remove { CommunicationObject.Closing -= value; }
 76        }
 77
 78        public event EventHandler Faulted
 79        {
 80            add { CommunicationObject.Faulted += value; }
 81            remove { CommunicationObject.Faulted -= value; }
 82        }
 83
 84        public event EventHandler Opened
 85        {
 86            add { CommunicationObject.Opened += value; }
 87            remove { CommunicationObject.Opened -= value; }
 88        }
 89
 90        public event EventHandler Opening
 91        {
 92            add { CommunicationObject.Opening += value; }
 93            remove { CommunicationObject.Opening -= value; }
 94        }
 95
 96        public CommunicationState State => CommunicationObject.State;
 97
 98        public virtual TimeSpan DefaultOpenTimeout => ServiceDefaults.OpenTimeout;
 99
 100        public virtual TimeSpan DefaultCloseTimeout => ServiceDefaults.CloseTimeout;
 101
 102        // communication object
 103        public void Abort()
 104        {
 105            CommunicationObject.Abort();
 106        }
 107
 108
 109        public virtual void OnClose(TimeSpan timeout)
 110        {
 111        }
 112
 113        public Task OnCloseAsync(TimeSpan timeout)
 114        {
 115            return Task.CompletedTask;
 116        }
 117
 118        public virtual void OnFaulted()
 119        {
 120            Abort();
 121        }
 122
 123        public virtual void OnOpen(TimeSpan timeout)
 124        {
 125        }
 126
 127        public Task OnOpenAsync(TimeSpan timeout)
 128        {
 129            return Task.CompletedTask;
 130        }
 131
 132        public virtual Task CloseAsync()
 133        {
 134            return Task.CompletedTask;
 135        }
 136
 137        public virtual Task CloseAsync(CancellationToken token)
 138        {
 139            return Task.CompletedTask;
 140        }
 141
 142        public virtual Task OpenAsync()
 143        {
 144            return Task.CompletedTask;
 145        }
 146
 147        public virtual Task OpenAsync(CancellationToken token)
 148        {
 149            return Task.CompletedTask;
 150        }
 151
 152        public virtual void OnAbort()
 153        {
 154        }
 155
 156        public void OnClosed()
 157        {
 158            throw new NotImplementedException();
 159        }
 160
 161        public void OnClosing()
 162        {
 163            throw new NotImplementedException();
 164        }
 165
 166        public void OnOpened()
 167        {
 168            throw new NotImplementedException();
 169        }
 170
 171        public void OnOpening()
 172        {
 173            throw new NotImplementedException();
 174        }
 175    }
 176}