< Summary

Information
Class: RoleRadar.Domain.Tracking.Application
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Tracking/Application.cs
Line coverage
97%
Covered lines: 97
Uncovered lines: 3
Coverable lines: 100
Total lines: 210
Line coverage: 97%
Branch coverage
88%
Covered branches: 55
Total branches: 62
Branch coverage: 88.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_OwnerId()100%11100%
get_PostingId()100%11100%
get_SubmittedDate()100%11100%
get_DesiredSalary()100%11100%
get_TargetStartDate()100%11100%
get_ResumeVariant()100%11100%
get_ResumePointer()100%11100%
get_ReferralContactId()100%11100%
get_ConfirmationCode()100%11100%
get_Outcome()100%11100%
get_OutcomeReason()100%11100%
get_VersionToken()100%11100%
get_CreatedAt()100%11100%
get_UpdatedAt()100%11100%
Create(...)86.95%464696.29%
Rehydrate(...)100%11100%
ApplyEvent(...)87.5%161692.3%

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Tracking/Application.cs

#LineLine coverage
 1using System.Globalization;
 2
 3namespace RoleRadar.Domain.Tracking;
 4
 5public sealed class Application
 6{
 7    public const int MaxResumePointerLength = 300;
 8    public const int MaxConfirmationCodeLength = 100;
 9    public const int MaxOutcomeReasonLength = 500;
 10
 1142011    public Guid Id { get; init; }
 1197012    public string OwnerId { get; init; } = string.Empty;
 620213    public Guid PostingId { get; init; }
 758214    public string SubmittedDate { get; private set; } = string.Empty;
 984215    public DesiredSalary DesiredSalary { get; private set; } = new();
 375016    public string? TargetStartDate { get; private set; }
 376417    public ResumeVariant ResumeVariant { get; private set; }
 375618    public string? ResumePointer { get; private set; }
 375019    public Guid? ReferralContactId { get; private set; }
 375620    public string? ConfirmationCode { get; private set; }
 685821    public ApplicationOutcome Outcome { get; private set; } = ApplicationOutcome.Applied;
 425022    public string? OutcomeReason { get; private set; }
 448623    public Guid VersionToken { get; private set; }
 823224    public DateTimeOffset CreatedAt { get; init; }
 420825    public DateTimeOffset UpdatedAt { get; private set; }
 26
 27    public static Application Create(
 28        string ownerId,
 29        Guid postingId,
 30        string submittedDate,
 31        ResumeVariant resumeVariant,
 32        DesiredSalary? desiredSalary = null,
 33        string? targetStartDate = null,
 34        string? resumePointer = null,
 35        Guid? referralContactId = null,
 36        string? confirmationCode = null,
 37        ApplicationOutcome outcome = ApplicationOutcome.Applied,
 38        string? outcomeReason = null,
 39        Guid? id = null,
 40        Guid? versionToken = null,
 41        DateTimeOffset? now = null)
 42    {
 129443        ArgumentException.ThrowIfNullOrWhiteSpace(ownerId);
 129444        if (postingId == Guid.Empty)
 45        {
 046            throw new ArgumentException("Posting ID cannot be empty.", nameof(postingId));
 47        }
 48
 129449        ArgumentException.ThrowIfNullOrWhiteSpace(submittedDate);
 129050        if (!DateOnly.TryParseExact(submittedDate.Trim(), "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.Non
 51        {
 852            throw new ArgumentException($"Submitted date must be in YYYY-MM-DD format: '{submittedDate}'.", nameof(submi
 53        }
 54
 128255        string? validatedTargetStartDate = null;
 128256        if (!string.IsNullOrWhiteSpace(targetStartDate))
 57        {
 858            if (!DateOnly.TryParseExact(targetStartDate.Trim(), "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyl
 59            {
 660                throw new ArgumentException($"Target start date must be in YYYY-MM-DD format: '{targetStartDate}'.", nam
 61            }
 262            validatedTargetStartDate = targetStartDate.Trim();
 63        }
 64
 127665        var salary = desiredSalary ?? new DesiredSalary();
 127666        if (salary.Min.HasValue && salary.Min.Value < 0)
 67        {
 468            throw new ArgumentException("Desired salary minimum must be >= 0.", nameof(desiredSalary));
 69        }
 70
 127271        if (salary.Min.HasValue && salary.Max.HasValue && salary.Max.Value < salary.Min.Value)
 72        {
 273            throw new ArgumentException("Desired salary maximum must be greater than or equal to minimum.", nameof(desir
 74        }
 75
 127076        if (string.IsNullOrWhiteSpace(salary.Currency) || salary.Currency.Trim().Length != 3)
 77        {
 478            throw new ArgumentException("Desired salary currency must be a 3-character currency code.", nameof(desiredSa
 79        }
 80
 126681        string? validatedResumePointer = null;
 126682        if (resumePointer is not null)
 83        {
 1284            if (resumePointer.Length > MaxResumePointerLength)
 85            {
 286                throw new ArgumentException($"Resume pointer cannot exceed {MaxResumePointerLength} characters.", nameof
 87            }
 88
 1089            if (resumePointer.Contains('\r') || resumePointer.Contains('\n'))
 90            {
 291                throw new ArgumentException("Resume pointer cannot contain newline characters or raw resume document con
 92            }
 93
 894            validatedResumePointer = resumePointer.Trim();
 95        }
 96
 126297        string? validatedConfirmationCode = null;
 126298        if (confirmationCode is not null)
 99        {
 10100            if (confirmationCode.Length > MaxConfirmationCodeLength)
 101            {
 2102                throw new ArgumentException($"Confirmation code cannot exceed {MaxConfirmationCodeLength} characters.", 
 103            }
 8104            validatedConfirmationCode = confirmationCode.Trim();
 105        }
 106
 1260107        string? validatedOutcomeReason = null;
 1260108        if (outcomeReason is not null)
 109        {
 16110            if (outcomeReason.Length > MaxOutcomeReasonLength)
 111            {
 0112                throw new ArgumentException($"Outcome reason cannot exceed {MaxOutcomeReasonLength} characters.", nameof
 113            }
 16114            validatedOutcomeReason = outcomeReason.Trim();
 115        }
 116
 1260117        var ts = now ?? DateTimeOffset.UtcNow;
 1260118        return new Application
 1260119        {
 1260120            Id = id ?? Guid.CreateVersion7(),
 1260121            OwnerId = ownerId.Trim(),
 1260122            PostingId = postingId,
 1260123            SubmittedDate = submittedDate.Trim(),
 1260124            DesiredSalary = salary,
 1260125            TargetStartDate = validatedTargetStartDate,
 1260126            ResumeVariant = resumeVariant,
 1260127            ResumePointer = validatedResumePointer,
 1260128            ReferralContactId = referralContactId,
 1260129            ConfirmationCode = validatedConfirmationCode,
 1260130            Outcome = outcome,
 1260131            OutcomeReason = validatedOutcomeReason,
 1260132            VersionToken = versionToken ?? Guid.CreateVersion7(),
 1260133            CreatedAt = ts,
 1260134            UpdatedAt = ts
 1260135        };
 136    }
 137
 138    public static Application Rehydrate(
 139        Guid id,
 140        string ownerId,
 141        Guid postingId,
 142        string submittedDate,
 143        DesiredSalary desiredSalary,
 144        string? targetStartDate,
 145        ResumeVariant resumeVariant,
 146        string? resumePointer,
 147        Guid? referralContactId,
 148        string? confirmationCode,
 149        ApplicationOutcome outcome,
 150        string? outcomeReason,
 151        Guid versionToken,
 152        DateTimeOffset createdAt,
 153        DateTimeOffset updatedAt)
 154    {
 240155        return new Application
 240156        {
 240157            Id = id,
 240158            OwnerId = ownerId,
 240159            PostingId = postingId,
 240160            SubmittedDate = submittedDate,
 240161            DesiredSalary = desiredSalary,
 240162            TargetStartDate = targetStartDate,
 240163            ResumeVariant = resumeVariant,
 240164            ResumePointer = resumePointer,
 240165            ReferralContactId = referralContactId,
 240166            ConfirmationCode = confirmationCode,
 240167            Outcome = outcome,
 240168            OutcomeReason = outcomeReason,
 240169            VersionToken = versionToken,
 240170            CreatedAt = createdAt,
 240171            UpdatedAt = updatedAt
 240172        };
 173    }
 174
 175    public void ApplyEvent(ApplicationEventType eventType, string? notes, DateTimeOffset timestamp)
 176    {
 1352177        var trimmedNotes = string.IsNullOrWhiteSpace(notes) ? null : notes.Trim();
 1352178        if (trimmedNotes is not null && trimmedNotes.Length > MaxOutcomeReasonLength)
 179        {
 0180            trimmedNotes = trimmedNotes[..MaxOutcomeReasonLength];
 181        }
 182
 183        switch (eventType)
 184        {
 185            case ApplicationEventType.Offer:
 186            case ApplicationEventType.Applied:
 187            case ApplicationEventType.FollowUp:
 188            case ApplicationEventType.Interview:
 189            case ApplicationEventType.Note:
 190                // Non-terminal events: outcome remains unchanged
 191                break;
 192
 193            case ApplicationEventType.Rejected:
 322194                Outcome = ApplicationOutcome.Rejected;
 322195                OutcomeReason = trimmedNotes;
 322196                UpdatedAt = timestamp;
 322197                VersionToken = Guid.CreateVersion7();
 322198                break;
 199
 200            case ApplicationEventType.OfferAccepted:
 201            case ApplicationEventType.OfferDeclined:
 202            case ApplicationEventType.Withdrawn:
 126203                Outcome = ApplicationOutcome.Closed;
 126204                OutcomeReason = trimmedNotes;
 126205                UpdatedAt = timestamp;
 126206                VersionToken = Guid.CreateVersion7();
 207                break;
 208        }
 1030209    }
 210}