< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Services.ScopeInvitationNoticeText
Assembly: ArturRios.Heimdall.Command
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Application/ArturRios.Heimdall.Command/Services/ScopeInvitationNoticeText.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 62
Line coverage: 100%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage
100%
Covered methods: 4
Fully covered methods: 4
Total methods: 4
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Invitation(...)100%11100%
Answer(...)100%22100%
OneLine(...)100%88100%
Format(...)100%11100%

File(s)

/home/ci/agent/workspace/heimdall-api-docs_main/app/src/Application/ArturRios.Heimdall.Command/Services/ScopeInvitationNoticeText.cs

#LineLine coverage
 1using System.Globalization;
 2using System.Text;
 3
 4namespace ArturRios.Heimdall.Command.Services;
 5
 6/// <summary>
 7///     The exact wording of the scope owner invitation notices (UC-21, UC-60, UC-61), kept beside the port so
 8///     the logging and Mailgun senders cannot drift from the sentence the specification fixes.
 9/// </summary>
 10/// <remarks>
 11///     The names come from records administrators control — a Scope Admin can rename themselves — and reach
 12///     another person's mailbox, so each is folded onto one line (<see cref="OneLine" />). Nothing a caller
 13///     controls is put in a subject.
 14/// </remarks>
 15public static class ScopeInvitationNoticeText
 16{
 17    public const string InvitationSubject = "You were invited to co-own a scope";
 18
 19    public const string AnswerSubject = "Your scope invitation was answered";
 20
 21    /// <summary>The invitee's notice. No token and no link (TH-41).</summary>
 22    public static string Invitation(string inviterName, string scopeName, DateTime expiresAt) =>
 723        $"{OneLine(inviterName)} invited you to co-own the scope {OneLine(scopeName)}. " +
 724        $"Sign in to Heimdall to accept or decline. The invitation expires on {Format(expiresAt)}.";
 25
 26    /// <summary>The inviter's notice once the invitee answered.</summary>
 27    public static string Answer(string inviteeName, string scopeName, bool accepted) =>
 528        $"{OneLine(inviteeName)} {(accepted ? "accepted" : "declined")} your invitation to co-own the scope " +
 529        $"{OneLine(scopeName)}.";
 30
 31    /// <summary>
 32    ///     <paramref name="value" /> with every control character and every run of whitespace, line breaks and
 33    ///     Unicode line separators included, turned into one space, and none at either end.
 34    /// </summary>
 35    public static string OneLine(string value)
 36    {
 3137        var builder = new StringBuilder(value.Length);
 3138        var pendingSpace = false;
 39
 66440        foreach (var character in value)
 41        {
 30142            if (char.IsControl(character) || char.IsWhiteSpace(character))
 43            {
 3644                pendingSpace = builder.Length > 0;
 45
 3646                continue;
 47            }
 48
 26549            if (pendingSpace)
 50            {
 2151                builder.Append(' ');
 2152                pendingSpace = false;
 53            }
 54
 26555            builder.Append(character);
 56        }
 57
 3158        return builder.ToString();
 59    }
 60
 761    private static string Format(DateTime at) => at.ToString("yyyy-MM-dd HH:mm 'UTC'", CultureInfo.InvariantCulture);
 62}