< Summary - CoreWCF Coverage — PR #1766

Information
Class: CoreWCF.Dispatcher.HelpPage
Assembly: CoreWCF.WebHttp
File(s): /home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Dispatcher/HelpPage.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 52
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
GetOperationTemplatePairs()100%110%
Invoke(...)0%440%
GetHelpPage()0%220%

File(s)

/home/runner/work/CoreWCF/CoreWCF/src/CoreWCF.WebHttp/src/CoreWCF/Dispatcher/HelpPage.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.Net;
 6using CoreWCF.Channels;
 7using CoreWCF.Web;
 8
 9namespace CoreWCF.Dispatcher
 10{
 11    internal class HelpPage
 12    {
 13        public const string OperationListHelpPageUriTemplate = "help";
 14        public const string OperationHelpPageUriTemplate = "help/operations/{operation}";
 15        private const string HelpMethodName = "GetHelpPage";
 16        private const string HelpOperationMethodName = "GetOperationHelpPage";
 17
 18        public static IEnumerable<KeyValuePair<UriTemplate, object>> GetOperationTemplatePairs()
 19        {
 020            return new KeyValuePair<UriTemplate, object>[]
 021            {
 022                new KeyValuePair<UriTemplate, object>(new UriTemplate(OperationListHelpPageUriTemplate), HelpMethodName)
 023                new KeyValuePair<UriTemplate, object>(new UriTemplate(OperationHelpPageUriTemplate), HelpOperationMethod
 024            };
 25        }
 26
 27        public object Invoke(UriTemplateMatch match)
 28        {
 029            switch ((string)match.Data)
 30            {
 31                case HelpMethodName:
 32                case HelpOperationMethodName:
 033                    return GetHelpPage();
 34                default:
 035                    return null;
 36            }
 37        }
 38
 39        private Message GetHelpPage()
 40        {
 041            if (WebOperationContext.Current != null)
 42            {
 043                WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.Redirect;
 044                WebOperationContext.Current.OutgoingResponse.Headers.Add("Location", "/swagger/index.html");
 45
 046                return Message.CreateMessage(MessageVersion.None, null);
 47            }
 48
 049            return null;
 50        }
 51    }
 52}