< Summary - SonghayCore

Information
Class: Songhay.Extensions.ProgramMetadataExtensions
Assembly: SonghayCore
File(s): /home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ProgramMetadataExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 15
Coverable lines: 15
Total lines: 36
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Method coverage is only available for sponsors.

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
ToConventionalHeaders(...)0%40%

File(s)

/home/rasx/sourceRoot/SonghayCore/SonghayCore/Extensions/ProgramMetadataExtensions.cs

#LineLine coverage
 1using System.Net.Http.Headers;
 2
 3namespace Songhay.Extensions;
 4
 5/// <summary>
 6/// Extensions of <see cref="ProgramMetadata"/>.
 7/// </summary>
 8public static class ProgramMetadataExtensions
 9{
 10    /// <summary>
 11    /// Converts <see cref="ProgramMetadata" />
 12    /// to the conventional <see cref="HttpRequestHeaders"/>.
 13    /// </summary>
 14    /// <param name="meta">The <see cref="ProgramMetadata"/>.</param>
 15    /// <param name="restApiMetadataSetKey">The key for <see cref="ProgramMetadata.RestApiMetadataSet"/>.</param>
 16    public static Dictionary<string, string> ToConventionalHeaders(this ProgramMetadata? meta,
 17        string restApiMetadataSetKey)
 018    {
 019        ArgumentNullException.ThrowIfNull(meta);
 20
 021        var genWebApiMeta = meta.RestApiMetadataSet.TryGetValueWithKey(restApiMetadataSetKey);
 022        if (genWebApiMeta == null) throw new NullReferenceException(nameof(genWebApiMeta));
 23
 024        var headers = new Dictionary<string, string>
 025        {
 026            {
 027                genWebApiMeta.ClaimsSet.TryGetValueWithKey(RestApiMetadata.ClaimsSetHeaderApiKey).ToReferenceTypeValueOr
 028                genWebApiMeta.ApiKey ??
 029                throw new NullReferenceException(
 030                    $"The expected {nameof(RestApiMetadata.ClaimsSetHeaderApiKey)} is not here.")
 031            }
 032        };
 33
 034        return headers;
 035    }
 36}