< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.ChannelDispatcherCollection
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/ChannelDispatcherCollection.cs
Line coverage
24%
Covered lines: 8
Uncovered lines: 25
Coverable lines: 33
Total lines: 88
Line coverage: 24.2%
Branch coverage
20%
Covered branches: 4
Total branches: 20
Branch coverage: 20%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)50%22100%
ClearItems()0%440%
InsertItem(...)75%4483.33%
RemoveItem(...)0%220%
SetItem(...)0%880%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Dispatcher/ChannelDispatcherCollection.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.Collections.Generic;
 6
 7namespace CoreWCF.Dispatcher
 8{
 9    public class ChannelDispatcherCollection : SynchronizedCollection<ChannelDispatcherBase>
 10    {
 11        private readonly ServiceHostBase _service;
 12
 13        internal ChannelDispatcherCollection(ServiceHostBase service, object syncRoot)
 59114            : base(syncRoot)
 15        {
 59116            _service = service ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(service));
 59117        }
 18
 19        protected override void ClearItems()
 20        {
 021            ChannelDispatcherBase[] array = new ChannelDispatcherBase[Count];
 022            CopyTo(array, 0);
 023            base.ClearItems();
 24
 025            if (_service != null)
 26            {
 027                foreach (ChannelDispatcherBase channelDispatcher in array)
 28                {
 029                    _service.OnRemoveChannelDispatcher(channelDispatcher);
 30                }
 31            }
 032        }
 33
 34        protected override void InsertItem(int index, ChannelDispatcherBase item)
 35        {
 64036            if (_service != null)
 37            {
 64038                if (_service.State == CommunicationState.Closed)
 39                {
 040                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(_service.GetTy
 41                }
 42
 64043                _service.OnAddChannelDispatcher(item);
 44            }
 45
 64046            base.InsertItem(index, item);
 64047        }
 48
 49        protected override void RemoveItem(int index)
 50        {
 051            ChannelDispatcherBase channelDispatcher = Items[index];
 052            base.RemoveItem(index);
 053            if (_service != null)
 54            {
 055                _service.OnRemoveChannelDispatcher(channelDispatcher);
 56            }
 057        }
 58
 59        protected override void SetItem(int index, ChannelDispatcherBase item)
 60        {
 061            if (_service != null)
 62            {
 063                if (_service.State == CommunicationState.Closed)
 64                {
 065                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ObjectDisposedException(_service.GetTy
 66                }
 67            }
 68
 069            if (_service != null)
 70            {
 071                _service.OnAddChannelDispatcher(item);
 72            }
 73
 74            ChannelDispatcherBase old;
 75
 076            lock (SyncRoot)
 77            {
 078                old = Items[index];
 079                base.SetItem(index, item);
 080            }
 81
 082            if (_service != null)
 83            {
 084                _service.OnRemoveChannelDispatcher(old);
 85            }
 086        }
 87    }
 88}