< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Configuration.ServiceOptions<T>
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Configuration/ServiceOptions.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 63
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.ctor(...)100%11100%
ApplyOptions(...)100%22100%
ApplyOptionsToServiceHost()100%44100%
SetNoOptionsDelegateDefaults()100%11100%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Configuration/ServiceOptions.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 CoreWCF.Description;
 7
 8namespace CoreWCF.Configuration
 9{
 10    public class ServiceOptions
 11    {
 12        internal ServiceOptions() { }
 13
 14        public ServiceDebugBehavior DebugBehavior { get; } = new ServiceDebugBehavior();
 15
 16        public ICollection<Uri> BaseAddresses { get; } = new List<Uri>();
 17    }
 18
 19    internal class ServiceOptions<TService> : ServiceOptions where TService : class
 20    {
 21        private ServiceHostObjectModel<TService> _serviceHost;
 57622        internal ServiceOptions(ServiceHostObjectModel<TService> serviceHost)
 23        {
 57624            _serviceHost = serviceHost;
 57625        }
 26
 27        internal void ApplyOptions(ServiceConfigurationDelegateHolder configDelegateHolder)
 28        {
 57629            bool optionsDelegateProvided = configDelegateHolder.ApplyOptions(this);
 57630            if (optionsDelegateProvided)
 31            {
 3532                ApplyOptionsToServiceHost();
 33            }
 34            else
 35            {
 54136                SetNoOptionsDelegateDefaults();
 37            }
 54138        }
 39
 40        private void ApplyOptionsToServiceHost()
 41        {
 3542            _serviceHost.Description.Behaviors.Remove<ServiceDebugBehavior>();
 3543            _serviceHost.Description.Behaviors.Add(DebugBehavior);
 3544            if (BaseAddresses.Count > 0)
 45            {
 3346                _serviceHost.InternalBaseAddresses.Clear();
 14647                foreach (Uri baseAddress in BaseAddresses)
 48                {
 4049                    _serviceHost.InternalBaseAddresses.Add(baseAddress);
 50                }
 51            }
 3552        }
 53
 54        private void SetNoOptionsDelegateDefaults()
 55        {
 56            // Enabling the debug page is a change in behavior which might take people by surprise
 57            // This code runs when not using the new options overload of AddService so only apps
 58            // which use the options overload will have the HttpHelpPageEnabled enabled by default.
 59            // That requires a code change so change is expected.
 54160            DebugBehavior.HttpHelpPageEnabled = false;
 54161        }
 62    }
 63}