< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.PerSessionInstanceContextProvider
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/PerSessionInstanceContextProvider.cs
Line coverage
80%
Covered lines: 8
Uncovered lines: 2
Coverable lines: 10
Total lines: 53
Line coverage: 80%
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%
GetExistingInstanceContext(...)50%22100%
InitializeInstanceContext(...)100%44100%
IsIdle(...)100%110%
NotifyIdle(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/PerSessionInstanceContextProvider.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;
 6using CoreWCF.Runtime;
 7
 8namespace CoreWCF.Dispatcher
 9{
 10    internal class PerSessionInstanceContextProvider : InstanceContextProviderBase
 11    {
 12        internal PerSessionInstanceContextProvider(DispatchRuntime dispatchRuntime)
 52613            : base(dispatchRuntime)
 14        {
 52615        }
 16
 17        public override InstanceContext GetExistingInstanceContext(Message message, IContextChannel channel)
 18        {
 19            // Here is the flow for a Sessionful channel
 20            //  1. First request comes in on new channel.
 21            //  2. ServiceChannel.InstanceContext is returned which is null.
 22            //  3. InstanceBehavior.EnsureInstanceContext will create a new InstanceContext.
 23            //  4. this.InitializeInstanceContext is called with the newly created InstanceContext and the channel.
 24            //  5. If the channel is sessionful then its bound to the InstanceContext.
 25            //  6. Bind channel to the InstanceContext.
 26            //  7. For all further requests on the same channel, we will return ServiceChannel.InstanceContext which wil
 229327            ServiceChannel serviceChannel = GetServiceChannelFromProxy(channel);
 28            Fx.Assert((serviceChannel != null), "CoreWCF.Dispatcher.PerSessionInstanceContextProvider.GetExistingInstanc
 229329            return serviceChannel?.InstanceContext;
 30        }
 31
 32        public override void InitializeInstanceContext(InstanceContext instanceContext, Message message, IContextChannel
 33        {
 227434            ServiceChannel serviceChannel = GetServiceChannelFromProxy(channel);
 227435            if (serviceChannel != null && serviceChannel.HasSession)
 36            {
 3637                instanceContext.BindIncomingChannel(serviceChannel);
 38            }
 227439        }
 40
 41
 42        public override bool IsIdle(InstanceContext instanceContext)
 43        {
 44            //By default return true
 045            return true;
 46        }
 47
 48        public override void NotifyIdle(Action<InstanceContext> callback, InstanceContext instanceContext)
 49        {
 50            //no-op
 051        }
 52    }
 53}