< Summary - SonghayCore

Information
Class: Songhay.Models.RestApiMetadata
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/RestApiMetadata.cs
Line coverage
10%
Covered lines: 3
Uncovered lines: 25
Coverable lines: 28
Total lines: 91
Line coverage: 10.7%
Branch coverage
0%
Covered branches: 0
Total branches: 20
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_ApiBase()100%1100%
get_ApiKey()100%10%
get_ClaimsSet()100%1100%
get_UriTemplates()100%1100%
ToString()0%200%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Models/RestApiMetadata.cs

#LineLine coverage
 1namespace Songhay.Models;
 2
 3/// <summary>
 4/// REST API Metadata
 5/// </summary>
 6public class RestApiMetadata
 7{
 8    /// <summary>
 9    /// A convential name representing an API key
 10    /// to sent in the HTTP headers for authentication.
 11    /// </summary>
 12    /// <remarks>
 13    /// Usually <c>"headerAuthorization": "Authorization"</c>.
 14    ///
 15    /// See https://docs.microsoft.com/en-us/rest/api/azure/#request-header
 16    /// </remarks>
 17    public const string ClaimsSetHeaderApiAuthorization = "headerAuthorization";
 18
 19    /// <summary>
 20    /// A convential name representing an API key
 21    /// to sent in the HTTP headers for authentication.
 22    /// </summary>
 23    /// <remarks>
 24    /// Usually <c>"headerContentType": "Content-Type"</c>.
 25    ///
 26    /// See https://docs.microsoft.com/en-us/rest/api/azure/#request-header
 27    /// </remarks>
 28    public const string ClaimsSetHeaderApiContentType = "headerContentType";
 29
 30    /// <summary>
 31    /// A convential name representing an API key
 32    /// to sent in the HTTP headers for authentication.
 33    /// </summary>
 34    /// <remarks>
 35    /// Usually <c>"headerKey": "X-ApiKey"</c>.
 36    /// </remarks>
 37    public const string ClaimsSetHeaderApiKey = "headerKey";
 38
 39    /// <summary>
 40    /// Gets or sets the API base.
 41    /// </summary>
 442    public Uri? ApiBase { get; set; }
 43
 44    /// <summary>
 45    /// Gets or sets the API key.
 46    /// </summary>
 047    public string? ApiKey { get; set; }
 48
 49    /// <summary>
 50    /// Gets or sets the claims set.
 51    /// </summary>
 152    public Dictionary<string, string> ClaimsSet { get; set; } = new();
 53
 54    /// <summary>
 55    /// Gets or sets the URI templates.
 56    /// </summary>
 457    public Dictionary<string, string> UriTemplates { get; set; } = new();
 58
 59    /// <summary>
 60    /// Converts this instance into a <see cref="string"/> representation.
 61    /// </summary>
 62    public override string ToString()
 063    {
 064        var sb = new StringBuilder();
 65
 066        if (ApiBase != null) sb.AppendFormat("ApiBase: {0}", ApiBase);
 067        if (!string.IsNullOrWhiteSpace(ApiKey)) sb.Append($" ApiKey: {ApiKey}");
 68
 069        if (ClaimsSet is {Count: > 0})
 070        {
 071            sb.AppendLine($"{nameof(ClaimsSet)}:");
 072            foreach (var item in ClaimsSet)
 073            {
 074                sb.AppendLine($"    {item.Key}:");
 075                sb.AppendLine($"        {item.Value}");
 076            }
 077        }
 78
 079        if (UriTemplates is {Count: > 0})
 080        {
 081            sb.AppendLine($"{nameof(UriTemplates)}:");
 082            foreach (var item in UriTemplates)
 083            {
 084                sb.AppendLine($"    {item.Key}:");
 085                sb.AppendLine($"        {item.Value}");
 086            }
 087        }
 88
 089        return sb.Length > 0 ? sb.ToString().Trim() : base.ToString() ?? GetType().Name;
 090    }
 91}