< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Channels.NetTcpOptions
Assembly: CoreWCF.NetTcp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetTcp/src/CoreWCF/Channels/NetTcpOptions.cs
Line coverage
68%
Covered lines: 13
Uncovered lines: 6
Coverable lines: 19
Total lines: 47
Line coverage: 68.4%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
Listen(...)100%110%
Listen(...)100%11100%
Listen(...)100%11100%
Listen(...)50%44100%
ApplyEndpointDefaults(...)100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.NetTcp/src/CoreWCF/Channels/NetTcpOptions.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;
 6
 7namespace CoreWCF.Channels
 8{
 9    public class NetTcpOptions
 10    {
 24011        internal List<TcpListenOptions> CodeBackedListenOptions { get; } = new List<TcpListenOptions>();
 8012        public IServiceProvider ApplicationServices { get; internal set; }
 13
 14        public void Listen(string baseAddress)
 15        {
 16            try
 17            {
 018                var baseAddressUri = new Uri(baseAddress);
 019                Listen(new Uri(baseAddress));
 020            }
 021            catch(UriFormatException ufe)
 22            {
 023                throw new CommunicationException($"Unable to parse base address {baseAddress}", ufe);
 24            }
 025        }
 26
 15027        public void Listen(Uri baseAddress) => Listen(baseAddress, _ => { });
 28
 529        public void Listen(string baseAddress, Action<TcpListenOptions> configure) => Listen(new Uri(baseAddress), confi
 30
 31        public void Listen(Uri baseAddress, Action<TcpListenOptions> configure)
 32        {
 8033            if (baseAddress == null) throw new ArgumentNullException(nameof(baseAddress));
 8034            if (configure == null) throw new ArgumentNullException(nameof(configure));
 35
 8036            var listenOptions = new TcpListenOptions(baseAddress);
 8037            ApplyEndpointDefaults(listenOptions);
 8038            configure(listenOptions);
 8039            CodeBackedListenOptions.Add(listenOptions);
 8040        }
 41
 42        private void ApplyEndpointDefaults(TcpListenOptions listenOptions)
 43        {
 8044            listenOptions.NetTcpServerOptions = this;
 8045        }
 46    }
 47}