< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.CommunicationObjectExtensions
Assembly: CoreWCF.NetFramingBase
File(s): /home/runner/work/CoreWCF/CoreWCF/src/Common/src/DuplexChannels/CoreWCF/Channels/CommunicationObjectExtensions.cs
Line coverage
40%
Covered lines: 4
Uncovered lines: 6
Coverable lines: 10
Total lines: 46
Line coverage: 40%
Branch coverage
28%
Covered branches: 2
Total branches: 7
Branch coverage: 28.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
DoneReceivingInCurrentState(...)28.57%7744.44%
CreateNotOpenException(...)100%110%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/Common/src/DuplexChannels/CoreWCF/Channels/CommunicationObjectExtensions.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.Diagnostics;
 6using CoreWCF.Runtime;
 7
 8namespace CoreWCF.Channels
 9{
 10    internal static class CommunicationObjectExtensions
 11    {
 12        internal static bool DoneReceivingInCurrentState(this CommunicationObject communicationObject)
 13        {
 21514            communicationObject.ThrowPending();
 15
 21516            switch (communicationObject.State)
 17            {
 18                case CommunicationState.Created:
 019                    throw TraceUtility.ThrowHelperError(CreateNotOpenException(communicationObject), Guid.Empty, communi
 20
 21                case CommunicationState.Opening:
 022                    throw TraceUtility.ThrowHelperError(CreateNotOpenException(communicationObject), Guid.Empty, communi
 23
 24                case CommunicationState.Opened:
 21225                    return false;
 26
 27                case CommunicationState.Closing:
 028                    return true;
 29
 30                case CommunicationState.Closed:
 331                    return true;
 32
 33                case CommunicationState.Faulted:
 034                    return true;
 35
 36                default:
 037                    throw Fx.AssertAndThrow("DoneReceivingInCurrentState: Unknown CommunicationObject.state");
 38            }
 39        }
 40
 41        private static Exception CreateNotOpenException(CommunicationObject communicationObject)
 42        {
 043            return new InvalidOperationException(SR.Format(SRCommon.CommunicationObjectCannotBeUsed, communicationObject
 44        }
 45    }
 46}