< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Security.NegotiationTokenAuthenticatorStateCache<T>
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/NegotiationTokenAuthenticatorStateCache.cs
Line coverage
15%
Covered lines: 2
Uncovered lines: 11
Coverable lines: 13
Total lines: 51
Line coverage: 15.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
.ctor(...)100%11100%
AddState(...)0%220%
GetState(...)100%110%
RemoveState(...)100%110%
OnQuotaReached(...)100%110%
OnRemove(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Security/NegotiationTokenAuthenticatorStateCache.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;
 6using CoreWCF.Runtime;
 7
 8namespace CoreWCF.Security
 9{
 10    internal sealed class NegotiationTokenAuthenticatorStateCache<T> : TimeBoundedCache
 11        where T : NegotiationTokenAuthenticatorState
 12    {
 113        private static readonly int s_lowWaterMark = 50;
 14        private TimeSpan _cachingSpan;
 15
 16        public NegotiationTokenAuthenticatorStateCache(TimeSpan cachingSpan, int maximumCachedState)
 217            : base(s_lowWaterMark, maximumCachedState, null, PurgingMode.TimerBasedPurge, TimeSpan.FromTicks(cachingSpan
 18
 19        public void AddState(string context, T state)
 20        {
 021            DateTime expirationTime = TimeoutHelper.Add(DateTime.UtcNow, _cachingSpan);
 022            bool wasStateAdded = base.TryAddItem(context, state, expirationTime, false);
 023            if (!wasStateAdded)
 24            {
 025                throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new SecurityNegotiationException(SR.Format(S
 26            }
 27            //if (TD.NegotiateTokenAuthenticatorStateCacheRatioIsEnabled())
 28            //{
 29            //    TD.NegotiateTokenAuthenticatorStateCacheRatio(base.Count, base.Capacity);
 30            //}
 031        }
 32
 033        public T GetState(string context) => (GetItem(context) as T);
 34
 035        public void RemoveState(string context) => TryRemoveItem(context);//if (TD.NegotiateTokenAuthenticatorStateCache
 36
 37
 38        protected override ArrayList OnQuotaReached(Hashtable cacheTable) =>
 39            //if (TD.NegotiateTokenAuthenticatorStateCacheExceededIsEnabled())
 40            //{
 41            //    TD.NegotiateTokenAuthenticatorStateCacheExceeded(SR.GetString(SR.CachedNegotiationStateQuotaReached, t
 42            //}
 043            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new QuotaExceededException(SR.Format(SR.CachedNego
 44
 45        protected override void OnRemove(object item)
 46        {
 047            ((IDisposable)item).Dispose();
 048            base.OnRemove(item);
 049        }
 50    }
 51}