< Summary

Information
Class: RoleRadar.Domain.Tracking.CareerSource
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Tracking/CareerSource.cs
Line coverage
100%
Covered lines: 82
Uncovered lines: 0
Coverable lines: 82
Total lines: 175
Line coverage: 100%
Branch coverage
89%
Covered branches: 41
Total branches: 46
Branch coverage: 89.1%
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_CompanyId()100%11100%
get_AtsType()100%11100%
get_Tenant()100%11100%
get_Slug()100%11100%
get_FetchMethod()100%11100%
get_Notes()100%11100%
get_IsActive()100%11100%
get_VersionToken()100%11100%
get_CreatedAt()100%11100%
get_UpdatedAt()100%11100%
Create(...)90.9%2222100%
Rehydrate(...)100%11100%
Retire(...)100%22100%
Reactivate(...)100%22100%
Update(...)85%2020100%

File(s)

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

#LineLine coverage
 1namespace RoleRadar.Domain.Tracking;
 2
 3public sealed class CareerSource
 4{
 5    public const int MaxTenantLength = 100;
 6    public const int MaxSlugLength = 150;
 7    public const int MaxNotesLength = 500;
 8
 2669    public Guid Id { get; init; }
 38810    public string OwnerId { get; init; } = string.Empty;
 21411    public Guid CompanyId { get; init; }
 39012    public string AtsType { get; private set; } = string.Empty;
 26413    public string? Tenant { get; private set; }
 25814    public string? Slug { get; private set; }
 22615    public FetchMethod FetchMethod { get; private set; } = FetchMethod.Api;
 22016    public string? Notes { get; private set; }
 40817    public bool IsActive { get; private set; } = true;
 24418    public Guid VersionToken { get; private set; }
 19419    public DateTimeOffset CreatedAt { get; init; }
 21220    public DateTimeOffset UpdatedAt { get; private set; }
 21
 22    public static CareerSource Create(
 23        string ownerId,
 24        Guid companyId,
 25        string atsType,
 26        string? tenant = null,
 27        string? slug = null,
 28        FetchMethod fetchMethod = FetchMethod.Api,
 29        string? notes = null,
 30        bool isActive = true,
 31        Guid? id = null,
 32        DateTimeOffset? now = null)
 33    {
 6834        ArgumentException.ThrowIfNullOrWhiteSpace(ownerId);
 6835        ArgumentException.ThrowIfNullOrWhiteSpace(atsType);
 36
 6637        if (companyId == Guid.Empty)
 38        {
 439            throw new ArgumentException("Company ID cannot be empty.", nameof(companyId));
 40        }
 41
 6242        if (tenant is not null && tenant.Length > MaxTenantLength)
 43        {
 444            throw new ArgumentException($"Tenant cannot exceed {MaxTenantLength} characters.", nameof(tenant));
 45        }
 46
 5847        if (slug is not null && slug.Length > MaxSlugLength)
 48        {
 449            throw new ArgumentException($"Slug cannot exceed {MaxSlugLength} characters.", nameof(slug));
 50        }
 51
 5452        if (notes is not null && notes.Length > MaxNotesLength)
 53        {
 454            throw new ArgumentException($"Notes cannot exceed {MaxNotesLength} characters.", nameof(notes));
 55        }
 56
 5057        var timestamp = now ?? DateTimeOffset.UtcNow;
 58
 5059        return new CareerSource
 5060        {
 5061            Id = id ?? Guid.CreateVersion7(),
 5062            OwnerId = ownerId.Trim(),
 5063            CompanyId = companyId,
 5064            AtsType = atsType.Trim(),
 5065            Tenant = tenant?.Trim(),
 5066            Slug = slug?.Trim(),
 5067            FetchMethod = fetchMethod,
 5068            Notes = notes,
 5069            IsActive = isActive,
 5070            VersionToken = Guid.CreateVersion7(),
 5071            CreatedAt = timestamp,
 5072            UpdatedAt = timestamp
 5073        };
 74    }
 75
 76    public static CareerSource Rehydrate(
 77        Guid id,
 78        string ownerId,
 79        Guid companyId,
 80        string atsType,
 81        string? tenant,
 82        string? slug,
 83        FetchMethod fetchMethod,
 84        string? notes,
 85        bool isActive,
 86        Guid versionToken,
 87        DateTimeOffset createdAt,
 88        DateTimeOffset updatedAt)
 89    {
 9890        return new CareerSource
 9891        {
 9892            Id = id,
 9893            OwnerId = ownerId,
 9894            CompanyId = companyId,
 9895            AtsType = atsType,
 9896            Tenant = tenant,
 9897            Slug = slug,
 9898            FetchMethod = fetchMethod,
 9899            Notes = notes,
 98100            IsActive = isActive,
 98101            VersionToken = versionToken,
 98102            CreatedAt = createdAt,
 98103            UpdatedAt = updatedAt
 98104        };
 105    }
 106
 107    public void Retire(DateTimeOffset? now = null)
 108    {
 6109        IsActive = false;
 6110        VersionToken = Guid.CreateVersion7();
 6111        UpdatedAt = now ?? DateTimeOffset.UtcNow;
 6112    }
 113
 114    public void Reactivate(DateTimeOffset? now = null)
 115    {
 6116        IsActive = true;
 6117        VersionToken = Guid.CreateVersion7();
 6118        UpdatedAt = now ?? DateTimeOffset.UtcNow;
 6119    }
 120
 121    public void Update(
 122        string? atsType = null,
 123        string? tenant = null,
 124        string? slug = null,
 125        FetchMethod? fetchMethod = null,
 126        string? notes = null,
 127        bool? isActive = null,
 128        DateTimeOffset? now = null)
 129    {
 12130        if (!string.IsNullOrWhiteSpace(atsType))
 131        {
 6132            AtsType = atsType.Trim();
 133        }
 134
 12135        if (tenant is not null)
 136        {
 8137            if (tenant.Length > MaxTenantLength)
 138            {
 2139                throw new ArgumentException($"Tenant cannot exceed {MaxTenantLength} characters.", nameof(tenant));
 140            }
 6141            Tenant = tenant.Trim();
 142        }
 143
 10144        if (slug is not null)
 145        {
 8146            if (slug.Length > MaxSlugLength)
 147            {
 2148                throw new ArgumentException($"Slug cannot exceed {MaxSlugLength} characters.", nameof(slug));
 149            }
 6150            Slug = slug.Trim();
 151        }
 152
 8153        if (fetchMethod.HasValue)
 154        {
 6155            FetchMethod = fetchMethod.Value;
 156        }
 157
 8158        if (notes is not null)
 159        {
 4160            if (notes.Length > MaxNotesLength)
 161            {
 2162                throw new ArgumentException($"Notes cannot exceed {MaxNotesLength} characters.", nameof(notes));
 163            }
 2164            Notes = notes;
 165        }
 166
 6167        if (isActive.HasValue)
 168        {
 6169            IsActive = isActive.Value;
 170        }
 171
 6172        VersionToken = Guid.CreateVersion7();
 6173        UpdatedAt = now ?? DateTimeOffset.UtcNow;
 6174    }
 175}