< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.TerminatingOperationBehavior
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/TerminatingOperationBehavior.cs
Line coverage
64%
Covered lines: 11
Uncovered lines: 6
Coverable lines: 17
Total lines: 61
Line coverage: 64.7%
Branch coverage
71%
Covered branches: 10
Total branches: 14
Branch coverage: 71.4%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
AbortChannel(...)100%110%
CreateIfNecessary(...)100%22100%
IsTerminatingOperationBehaviorNeeded(...)100%44100%
AfterReply(...)100%44100%
AfterReply(...)0%440%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/TerminatingOperationBehavior.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 CoreWCF.Channels;
 7
 8namespace CoreWCF.Dispatcher
 9{
 10    internal class TerminatingOperationBehavior
 11    {
 12        private static void AbortChannel(object state)
 13        {
 014            ((IChannel)state).Abort();
 015        }
 16
 17        public static TerminatingOperationBehavior CreateIfNecessary(DispatchRuntime dispatch)
 18        {
 66119            if (IsTerminatingOperationBehaviorNeeded(dispatch))
 20            {
 421                return new TerminatingOperationBehavior();
 22            }
 23            else
 24            {
 65725                return null;
 26            }
 27        }
 28
 29        private static bool IsTerminatingOperationBehaviorNeeded(DispatchRuntime dispatch)
 30        {
 734031            for (int i = 0; i < dispatch.Operations.Count; i++)
 32            {
 301333                DispatchOperation operation = dispatch.Operations[i];
 34
 301335                if (operation.IsTerminating)
 36                {
 437                    return true;
 38                }
 39            }
 40
 65741            return false;
 42        }
 43
 44        internal void AfterReply(ref MessageRpc rpc)
 45        {
 1146            if (rpc.Operation.IsTerminating && rpc.Channel.HasSession)
 47            {
 448                Timer timer = new Timer(new TimerCallback(AbortChannel), rpc.Channel.Binder.Channel, rpc.Channel.CloseTi
 49            }
 1150        }
 51
 52        internal static void AfterReply(ref ProxyRpc rpc)
 53        {
 054            if (rpc.Operation.IsTerminating && rpc.Channel.HasSession)
 55            {
 056                IChannel sessionChannel = rpc.Channel.Binder.Channel;
 057                rpc.Channel.CloseAsync(rpc.CancellationToken).GetAwaiter().GetResult();
 58            }
 059        }
 60    }
 61}