< Summary

Information
Class: RoleRadar.Domain.Tracking.SearchRun
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Tracking/SearchRun.cs
Line coverage
91%
Covered lines: 34
Uncovered lines: 3
Coverable lines: 37
Total lines: 68
Line coverage: 91.8%
Branch coverage
71%
Covered branches: 10
Total branches: 14
Branch coverage: 71.4%
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_StartedAt()100%11100%
get_NewPostingsCount()100%11100%
get_ReportNoteId()100%11100%
get_Notes()100%11100%
get_CreatedAt()100%11100%
.ctor(...)70%101086.36%
Create(...)75%44100%

File(s)

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

#LineLine coverage
 1using RoleRadar.Domain.Common;
 2
 3namespace RoleRadar.Domain.Tracking;
 4
 5public sealed class SearchRun
 6{
 7    public const int MaxNotesLength = 500;
 8
 7189    public Guid Id { get; }
 67210    public string OwnerId { get; }
 33611    public DateTimeOffset StartedAt { get; }
 34612    public int NewPostingsCount { get; }
 34013    public Guid? ReportNoteId { get; }
 37014    public string? Notes { get; }
 36215    public DateTimeOffset CreatedAt { get; }
 16
 35217    public SearchRun(
 35218        Guid id,
 35219        string ownerId,
 35220        DateTimeOffset startedAt,
 35221        int newPostingsCount,
 35222        Guid? reportNoteId,
 35223        string? notes,
 35224        DateTimeOffset createdAt)
 25    {
 35226        if (id == Guid.Empty)
 27        {
 028            throw new ArgumentException("SearchRun id cannot be empty.", nameof(id));
 29        }
 30
 35231        OwnerId = new OwnerId(ownerId).Value;
 35232        StartedAt = startedAt;
 35233        if (newPostingsCount < 0)
 34        {
 035            throw new ArgumentOutOfRangeException(nameof(newPostingsCount), "NewPostingsCount must be >= 0.");
 36        }
 37
 35238        NewPostingsCount = newPostingsCount;
 35239        ReportNoteId = reportNoteId;
 35240        if (notes is not null && notes.Length > MaxNotesLength)
 41        {
 042            throw new ArgumentException($"Notes cannot exceed {MaxNotesLength} characters.", nameof(notes));
 43        }
 44
 35245        Notes = notes?.Trim();
 35246        CreatedAt = createdAt;
 35247        Id = id;
 35248    }
 49
 50    public static SearchRun Create(
 51        string ownerId,
 52        DateTimeOffset startedAt,
 53        int newPostingsCount,
 54        Guid? reportNoteId = null,
 55        string? notes = null,
 56        DateTimeOffset? createdAt = null,
 57        Guid? id = null)
 58    {
 33659        return new SearchRun(
 33660            id: id ?? Guid.CreateVersion7(),
 33661            ownerId: ownerId,
 33662            startedAt: startedAt,
 33663            newPostingsCount: newPostingsCount,
 33664            reportNoteId: reportNoteId,
 33665            notes: notes,
 33666            createdAt: createdAt ?? DateTimeOffset.UtcNow);
 67    }
 68}