< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.InstanceContextProviderBase
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/IInstanceContextProvider.cs
Line coverage
68%
Covered lines: 13
Uncovered lines: 6
Coverable lines: 19
Total lines: 91
Line coverage: 68.4%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
IsProviderSingleton(...)100%11100%
IsProviderSessionful(...)100%11100%
GetProviderForMode(...)75%4460%
IsProviderPerCall(...)100%11100%
GetServiceChannelFromProxy(...)100%22100%
GetExistingInstanceContext(...)100%110%
InitializeInstanceContext(...)100%110%
IsIdle(...)100%110%
NotifyIdle(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/IInstanceContextProvider.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 CoreWCF.Channels;
 6
 7namespace CoreWCF.Dispatcher
 8{
 9    public interface IInstanceContextProvider
 10    {
 11        InstanceContext GetExistingInstanceContext(Message message, IContextChannel channel);
 12        void InitializeInstanceContext(InstanceContext instanceContext, Message message, IContextChannel channel);
 13        bool IsIdle(InstanceContext instanceContext);
 14        void NotifyIdle(Action<InstanceContext> callback, InstanceContext instanceContext);
 15    }
 16
 17
 18    internal abstract class InstanceContextProviderBase : IInstanceContextProvider
 19    {
 8220        public DispatchRuntime DispatchRuntime { get; }
 21
 66422        internal InstanceContextProviderBase(DispatchRuntime dispatchRuntime)
 23        {
 66424            DispatchRuntime = dispatchRuntime;
 66425        }
 26
 27        internal static bool IsProviderSingleton(IInstanceContextProvider provider)
 28        {
 497629            return (provider is SingletonInstanceContextProvider);
 30        }
 31
 32        internal static bool IsProviderSessionful(IInstanceContextProvider provider)
 33        {
 272834            return (provider is PerSessionInstanceContextProvider);
 35        }
 36
 37        internal static IInstanceContextProvider GetProviderForMode(InstanceContextMode instanceMode, DispatchRuntime ru
 38        {
 39            switch (instanceMode)
 40            {
 41                case InstanceContextMode.PerCall:
 1342                    return new PerCallInstanceContextProvider(runtime);
 43                case InstanceContextMode.PerSession:
 52644                    return new PerSessionInstanceContextProvider(runtime);
 45                case InstanceContextMode.Single:
 10246                    return new SingletonInstanceContextProvider(runtime);
 47                default:
 048                    DiagnosticUtility.FailFast("InstanceContextProviderBase.GetProviderForMode: default");
 049                    return null;
 50            }
 51        }
 52
 53        internal static bool IsProviderPerCall(IInstanceContextProvider provider)
 54        {
 233255            return (provider is PerCallInstanceContextProvider);
 56        }
 57
 58        internal ServiceChannel GetServiceChannelFromProxy(IContextChannel channel)
 59        {
 469660            if (!(channel is ServiceChannel serviceChannel))
 61            {
 262                serviceChannel = ServiceChannelFactory.GetServiceChannel(channel);
 63            }
 469664            return serviceChannel;
 65        }
 66
 67        #region IInstanceContextProvider Members
 68
 69        public virtual InstanceContext GetExistingInstanceContext(Message message, IContextChannel channel)
 70        {
 071            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 72        }
 73
 74        public virtual void InitializeInstanceContext(InstanceContext instanceContext, Message message, IContextChannel 
 75        {
 076            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 77        }
 78
 79        public virtual bool IsIdle(InstanceContext instanceContext)
 80        {
 081            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 82        }
 83
 84        public virtual void NotifyIdle(Action<InstanceContext> callback, InstanceContext instanceContext)
 85        {
 086            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new NotImplementedException());
 87        }
 88
 89        #endregion
 90    }
 91}