< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.OperationSelectorBehavior
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/OperationSelectorBehavior.cs
Line coverage
70%
Covered lines: 19
Uncovered lines: 8
Coverable lines: 27
Total lines: 93
Line coverage: 70.3%
Branch coverage
75%
Covered branches: 15
Total branches: 20
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/OperationSelectorBehavior.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.Collections.Generic;
 5using System.Reflection;
 6using CoreWCF.Channels;
 7using CoreWCF.Description;
 8
 9namespace CoreWCF.Dispatcher
 10{
 11    internal class OperationSelectorBehavior : IContractBehavior
 12    {
 13        void IContractBehavior.Validate(ContractDescription description, ServiceEndpoint endpoint)
 14        {
 64115        }
 16
 17        void IContractBehavior.AddBindingParameters(ContractDescription description, ServiceEndpoint endpoint, BindingPa
 18        {
 67319        }
 20
 21        void IContractBehavior.ApplyDispatchBehavior(ContractDescription description, ServiceEndpoint endpoint, Dispatch
 22        {
 64123            if (dispatch.ClientRuntime != null)
 24            {
 225                dispatch.ClientRuntime.OperationSelector = new MethodInfoOperationSelector(description, MessageDirection
 26            }
 64127        }
 28
 29        void IContractBehavior.ApplyClientBehavior(ContractDescription description, ServiceEndpoint endpoint, ClientRunt
 30        {
 031            proxy.OperationSelector = new MethodInfoOperationSelector(description, MessageDirection.Input);
 032        }
 33
 34        internal class MethodInfoOperationSelector : IClientOperationSelector
 35        {
 36            private readonly Dictionary<object, string> _operationMap;
 37
 238            internal MethodInfoOperationSelector(ContractDescription description, MessageDirection directionThatRequires
 39            {
 240                _operationMap = new Dictionary<object, string>();
 41
 1642                for (int i = 0; i < description.Operations.Count; i++)
 43                {
 644                    OperationDescription operation = description.Operations[i];
 645                    if (operation.Messages[0].Direction == directionThatRequiresClientOpSelection)
 46                    {
 247                        if (operation.SyncMethod != null)
 48                        {
 249                            if (!_operationMap.ContainsKey(operation.SyncMethod))
 50                            {
 251                                _operationMap.Add(operation.SyncMethod, operation.Name);
 52                            }
 53                        }
 54
 255                        if (operation.BeginMethod != null)
 56                        {
 057                            if (!_operationMap.ContainsKey(operation.BeginMethod))
 58                            {
 059                                _operationMap.Add(operation.BeginMethod, operation.Name);
 060                                _operationMap.Add(operation.EndMethod, operation.Name);
 61                            }
 62                        }
 63
 264                        if (operation.TaskMethod != null)
 65                        {
 066                            if (!_operationMap.ContainsKey(operation.TaskMethod))
 67                            {
 068                                _operationMap.Add(operation.TaskMethod, operation.Name);
 69                            }
 70                        }
 71                    }
 72                }
 273            }
 74
 75            public bool AreParametersRequiredForSelection
 76            {
 177                get { return false; }
 78            }
 79
 80            public string SelectOperation(MethodBase method, object[] parameters)
 81            {
 182                if (_operationMap.ContainsKey(method))
 83                {
 184                    return _operationMap[method];
 85                }
 86                else
 87                {
 088                    return null;
 89                }
 90            }
 91        }
 92    }
 93}