< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.Command.Services.InviteeInvitationLookup
Assembly: ArturRios.Heimdall.Command
File(s): /home/ci/agent/workspace/heimdall-api-docs_main/app/src/Application/ArturRios.Heimdall.Command/Services/InviteeInvitationLookup.cs
Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 61
Line coverage: 93.7%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage
100%
Covered methods: 2
Fully covered methods: 1
Total methods: 2
Method coverage: 100%
Full method coverage: 50%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FindAsync()75%4490%
InviterToTellAsync()100%22100%

File(s)

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

#LineLine coverage
 1using ArturRios.Data.Relational.Core.Interfaces;
 2using ArturRios.Heimdall.Domain.Entities;
 3using Microsoft.EntityFrameworkCore;
 4
 5namespace ArturRios.Heimdall.Command.Services;
 6
 7/// <summary>
 8///     The reads UC-60 and UC-61 share: the caller's own open invitation, and the inviter who should hear the
 9///     answer.
 10/// </summary>
 11public static class InviteeInvitationLookup
 12{
 13    /// <summary>
 14    ///     The open invitation <paramref name="invitationId" />, with its invitee, if and only if it was made to
 15    ///     the caller; otherwise <c>null</c>. An unknown id, an ended or expired invitation and somebody else's
 16    ///     all give <c>null</c>, so inviter, invitee and outsider cannot tell them apart (AF-60a, AF-61a).
 17    /// </summary>
 18    public static async Task<(Person Invitee, ScopeOwnerInvitation Invitation)?> FindAsync(
 19        IAsyncReadOnlyRepository<Person, long> personReader,
 20        IAsyncReadOnlyRepository<ScopeOwnerInvitation, long> invitationReader,
 21        Guid actingPersonId,
 22        Guid invitationId,
 23        DateTime now,
 24        CancellationToken cancellationToken)
 25    {
 3326        var invitee = await personReader.Query()
 3327            .FirstOrDefaultAsync(x => x.PublicId == actingPersonId, cancellationToken);
 28
 3329        if (invitee is null)
 30        {
 031            return null;
 32        }
 33
 3334        var invitation = await invitationReader.Query()
 3335            .Where(x => x.PublicId == invitationId && x.InviteePersonId == invitee.Id)
 3336            .Where(ScopeOwnerInvitation.OpenAt(now))
 3337            .FirstOrDefaultAsync(cancellationToken);
 38
 3339        return invitation is null ? null : (invitee, invitation);
 3340    }
 41
 42    /// <summary>
 43    ///     The inviter, when there is still somebody to tell: not cleared by anonymisation or a hard delete, not
 44    ///     logically deleted or anonymised, and not processing-restricted, since a restricted person is mailed
 45    ///     nothing (NFR-24, AF-51c). <c>null</c> means no answer notice is sent.
 46    /// </summary>
 47    public static async Task<Person?> InviterToTellAsync(
 48        IAsyncReadOnlyRepository<Person, long> personReader,
 49        ScopeOwnerInvitation invitation,
 50        CancellationToken cancellationToken)
 51    {
 1552        if (invitation.InvitedByPersonId is not { } inviterId)
 53        {
 354            return null;
 55        }
 56
 1257        return await personReader.Query()
 1258            .FirstOrDefaultAsync(x => x.Id == inviterId && !x.IsDeleted && x.AnonymisedAt == null &&
 1259                                      x.ProcessingRestrictedAt == null, cancellationToken);
 1560    }
 61}

Methods/Properties

FindAsync()
InviterToTellAsync()