< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Queue.Common.Configuration.QueueMiddlewareBuilder
Assembly: CoreWCF.Queue
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Queue/src/CoreWCF/Queue/Common/Configuration/QueueMiddlewareBuilder.cs
Line coverage
81%
Covered lines: 18
Uncovered lines: 4
Coverable lines: 22
Total lines: 73
Line coverage: 81.8%
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%
.ctor(...)100%110%
Use(...)100%11100%
New()100%110%
Build()100%44100%
GetProperty(...)50%22100%
SetProperty(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Queue/src/CoreWCF/Queue/Common/Configuration/QueueMiddlewareBuilder.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.Collections.Generic;
 6using System.Linq;
 7using System.Threading.Tasks;
 8
 9namespace CoreWCF.Queue.Common.Configuration
 10{
 11    internal class QueueMiddlewareBuilder : IQueueMiddlewareBuilder
 12    {
 5013        private readonly IList<Func<QueueMessageDispatcherDelegate, QueueMessageDispatcherDelegate>> _components = new L
 14
 5015        public QueueMiddlewareBuilder(IServiceProvider serviceProvider)
 16        {
 5017            Properties = new Dictionary<string, object>(StringComparer.Ordinal);
 5018            Services = serviceProvider;
 5019        }
 20
 021        private QueueMiddlewareBuilder(QueueMiddlewareBuilder builder)
 22        {
 023            Properties = new Dictionary<string, object>(builder.Properties, StringComparer.Ordinal);
 024        }
 25
 26        public IServiceProvider Services
 27        {
 28            get
 29            {
 20030                return GetProperty("QueueMessage.Services") as IServiceProvider;
 31            }
 32            set
 33            {
 5034                SetProperty("QueueMessage.Services", value);
 5035            }
 36        }
 37
 25038        public IDictionary<string, object> Properties { get; }
 39
 40        public IQueueMiddlewareBuilder Use(Func<QueueMessageDispatcherDelegate, QueueMessageDispatcherDelegate> middlewa
 41        {
 10042            _components.Add(middleware);
 10043            return this;
 44        }
 45
 46        public IQueueMiddlewareBuilder New()
 47        {
 048            return new QueueMiddlewareBuilder(this);
 49        }
 50
 51        public QueueMessageDispatcherDelegate Build()
 52        {
 5053            QueueMessageDispatcherDelegate app = _ => Task.CompletedTask;
 54
 30055            foreach (Func<QueueMessageDispatcherDelegate, QueueMessageDispatcherDelegate> component in _components.Rever
 56            {
 10057                app = component(app);
 58            }
 59
 5060            return app;
 61        }
 62
 63        private object GetProperty(string key)
 64        {
 20065            return Properties.TryGetValue(key, out object value) ? value : default;
 66        }
 67
 68        private void SetProperty(string key, object value)
 69        {
 5070            Properties[key] = value;
 5071        }
 72    }
 73}