< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.FramingConnectionHandshakeBuilder
Assembly: CoreWCF.NetFramingBase
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetFramingBase/src/CoreWCF/Configuration/FramingConnectionHandshakeBuilder.cs
Line coverage
96%
Covered lines: 24
Uncovered lines: 1
Coverable lines: 25
Total lines: 76
Line coverage: 96%
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%11100%
GetProperty(...)50%22100%
SetProperty(...)100%11100%
Use(...)100%11100%
New()100%11100%
Build()100%4485.71%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetFramingBase/src/CoreWCF/Configuration/FramingConnectionHandshakeBuilder.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.Configuration
 10{
 11    public class FramingConnectionHandshakeBuilder : IFramingConnectionHandshakeBuilder
 12    {
 24913        private readonly IList<Func<HandshakeDelegate, HandshakeDelegate>> _components = new List<Func<HandshakeDelegate
 14
 8315        public FramingConnectionHandshakeBuilder(IServiceProvider serviceProvider)
 16        {
 8317            Properties = new Dictionary<string, object>(StringComparer.Ordinal);
 8318            HandshakeServices = serviceProvider;
 8319        }
 20
 16621        public FramingConnectionHandshakeBuilder(FramingConnectionHandshakeBuilder connectionHandshakeBuilder)
 22        {
 16623            Properties = new Dictionary<string, object>(connectionHandshakeBuilder.Properties, StringComparer.Ordinal);
 16624        }
 25
 26        public IServiceProvider HandshakeServices
 27        {
 28            get
 29            {
 136030                return GetProperty<IServiceProvider>("handshake.Services");
 31            }
 32            set
 33            {
 8334                SetProperty("handshake.Services", value);
 8335            }
 36        }
 37
 160938        public IDictionary<string, object> Properties { get; }
 39
 40        private T GetProperty<T>(string key)
 41        {
 136042            return Properties.TryGetValue(key, out object value) ? (T)value : default;
 43        }
 44
 45        private void SetProperty<T>(string key, T value)
 46        {
 8347            Properties[key] = value;
 8348        }
 49
 50        public IFramingConnectionHandshakeBuilder Use(Func<HandshakeDelegate, HandshakeDelegate> middleware)
 51        {
 91352            _components.Add(middleware);
 91353            return this;
 54        }
 55
 56        public IFramingConnectionHandshakeBuilder New()
 57        {
 16658            return new FramingConnectionHandshakeBuilder(this);
 59        }
 60
 61        public HandshakeDelegate Build()
 62        {
 24963            HandshakeDelegate app = context =>
 24964            {
 065                return Task.CompletedTask;
 24966            };
 67
 232468            foreach (Func<HandshakeDelegate, HandshakeDelegate> component in _components.Reverse())
 69            {
 91370                app = component(app);
 71            }
 72
 24973            return app;
 74        }
 75    }
 76}