< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Description.ServiceDebugBehavior
Assembly: CoreWCF.Primitives
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/ServiceDebugBehavior.cs
Line coverage
62%
Covered lines: 23
Uncovered lines: 14
Coverable lines: 37
Total lines: 105
Line coverage: 62.1%
Branch coverage
43%
Covered branches: 13
Total branches: 30
Branch coverage: 43.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.Primitives/src/CoreWCF/Description/ServiceDebugBehavior.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;
 6using System.Collections.ObjectModel;
 7using System.ComponentModel;
 8using System.Diagnostics;
 9using CoreWCF.Channels;
 10using CoreWCF.Diagnostics;
 11using CoreWCF.Dispatcher;
 12
 13namespace CoreWCF.Description
 14{
 15    public class ServiceDebugBehavior : IServiceBehavior
 16    {
 17        private Uri _httpHelpPageUrl;
 18        private Uri _httpsHelpPageUrl;
 19
 284920        public bool HttpHelpPageEnabled { get; set; } = true;
 21
 22        public Uri HttpHelpPageUrl
 23        {
 024            get { return _httpHelpPageUrl; }
 25            set
 26            {
 027                if (value != null && value.IsAbsoluteUri && value.Scheme != Uri.UriSchemeHttp)
 28                {
 029                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.Format(SR.SFxServiceMetadataBehavior
 030                        nameof(HttpHelpPageUrl), Uri.UriSchemeHttp, value.ToString(), value.Scheme));
 31                }
 32
 033                _httpHelpPageUrl = value;
 034            }
 35        }
 36
 173237        public bool HttpsHelpPageEnabled { get; set; } = true;
 38
 39        public Uri HttpsHelpPageUrl
 40        {
 041            get { return _httpsHelpPageUrl; }
 42            set
 43            {
 044                if (value != null && value.IsAbsoluteUri && value.Scheme != Uri.UriSchemeHttps)
 45                {
 046                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument(SR.Format(SR.SFxServiceMetadataBehavior
 047                        nameof(HttpsHelpPageUrl), Uri.UriSchemeHttps, value.ToString(), value.Scheme));
 48                }
 49
 050                _httpsHelpPageUrl = value;
 051            }
 52        }
 53
 54        [DefaultValue(false)]
 58755        public bool IncludeExceptionDetailInFaults { get; set; } = false;
 56
 57657        void IServiceBehavior.Validate(ServiceDescription description, ServiceHostBase serviceHostBase) { }
 58
 59        void IServiceBehavior.AddBindingParameters(ServiceDescription description, ServiceHostBase serviceHostBase, Coll
 60        {
 66461            if (parameters == null)
 62            {
 063                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(parameters));
 64            }
 65
 66466            ServiceDebugBehavior param = parameters.Find<ServiceDebugBehavior>();
 66467            if (param == null)
 68            {
 66469                parameters.Add(this);
 70            }
 66471        }
 72
 73        void IServiceBehavior.ApplyDispatchBehavior(ServiceDescription description, ServiceHostBase serviceHostBase)
 74        {
 57675            if (IncludeExceptionDetailInFaults)
 76            {
 6277                for (int i = 0; i < serviceHostBase.ChannelDispatchers.Count; i++)
 78                {
 2079                    ChannelDispatcher channelDispatcher = serviceHostBase.ChannelDispatchers[i] as ChannelDispatcher;
 2080                    if (channelDispatcher != null)
 81                    {
 2082                        channelDispatcher.IncludeExceptionDetailInFaults = true;
 83                    }
 84                }
 85            }
 86
 57687            if (!(HttpHelpPageEnabled || HttpsHelpPageEnabled))
 88            {
 089                return;
 90            }
 91
 57692            ServiceMetadataExtension mex = ServiceMetadataExtension.EnsureServiceMetadataExtension(serviceHostBase);
 57693            SetExtensionProperties(mex, serviceHostBase);
 57694        }
 95
 96        private void SetExtensionProperties(ServiceMetadataExtension mex, ServiceHostBase host)
 97        {
 57698            mex.HttpHelpPageEnabled = HttpHelpPageEnabled;
 57699            mex.HttpHelpPageUrl = host.GetVia(Uri.UriSchemeHttp, _httpHelpPageUrl == null ? new Uri(string.Empty, UriKin
 100
 576101            mex.HttpsHelpPageEnabled = HttpsHelpPageEnabled;
 576102            mex.HttpsHelpPageUrl = host.GetVia(Uri.UriSchemeHttps, _httpsHelpPageUrl == null ? new Uri(string.Empty, Uri
 576103        }
 104    }
 105}