< Summary

Information
Class: RoleRadar.Domain.Notes.NoteImportMetadata
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Notes/NoteImportMetadata.cs
Line coverage
88%
Covered lines: 37
Uncovered lines: 5
Coverable lines: 42
Total lines: 89
Line coverage: 88%
Branch coverage
50%
Covered branches: 6
Total branches: 12
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ImportKey()100%11100%
get_SourceFileId()100%11100%
get_HeadingPath()100%11100%
get_OccurrenceIndex()100%11100%
get_SectionOrderIndex()100%11100%
get_LastImportedBodyHash()100%11100%
.ctor(...)100%11100%
Create(...)50%141275%
Rehydrate(...)100%11100%
WithUpdatedImportState(...)100%11100%

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Notes/NoteImportMetadata.cs

#LineLine coverage
 1namespace RoleRadar.Domain.Notes;
 2
 3public sealed record NoteImportMetadata
 4{
 18325    public string ImportKey { get; }
 6
 8147    public string SourceFileId { get; }
 8
 8129    public string HeadingPath { get; }
 10
 81011    public int OccurrenceIndex { get; }
 12
 119413    public int SectionOrderIndex { get; }
 14
 183615    public string LastImportedBodyHash { get; }
 16
 164417    private NoteImportMetadata(
 164418        string importKey,
 164419        string sourceFileId,
 164420        string headingPath,
 164421        int occurrenceIndex,
 164422        int sectionOrderIndex,
 164423        string lastImportedBodyHash)
 24    {
 164425        ImportKey = importKey;
 164426        SourceFileId = sourceFileId;
 164427        HeadingPath = headingPath;
 164428        OccurrenceIndex = occurrenceIndex;
 164429        SectionOrderIndex = sectionOrderIndex;
 164430        LastImportedBodyHash = lastImportedBodyHash;
 164431    }
 32
 33    public static NoteImportMetadata Create(
 34        string sourceFileId,
 35        string headingPath,
 36        int occurrenceIndex,
 37        int sectionOrderIndex,
 38        string lastImportedBodyHash)
 39    {
 82240        if (string.IsNullOrWhiteSpace(sourceFileId))
 41        {
 042            throw new ArgumentException("Source file identifier is required.", nameof(sourceFileId));
 43        }
 44
 82245        if (string.IsNullOrWhiteSpace(headingPath))
 46        {
 047            throw new ArgumentException("Heading path is required.", nameof(headingPath));
 48        }
 49
 82250        if (occurrenceIndex < 0)
 51        {
 052            throw new ArgumentOutOfRangeException(nameof(occurrenceIndex), "Occurrence index cannot be negative.");
 53        }
 54
 82255        if (sectionOrderIndex < 0)
 56        {
 057            throw new ArgumentOutOfRangeException(nameof(sectionOrderIndex), "Section order index cannot be negative.");
 58        }
 59
 82260        if (string.IsNullOrWhiteSpace(lastImportedBodyHash) || lastImportedBodyHash.Length != 64)
 61        {
 062            throw new ArgumentException("Last-imported body hash must be a 64-character lowercase hex SHA-256 string.", 
 63        }
 64
 82265        var normalizedSourceId = sourceFileId.Trim();
 82266        var normalizedHeadingPath = headingPath.Trim();
 82267        var importKey = $"{normalizedSourceId}#{normalizedHeadingPath}#{occurrenceIndex}";
 68
 82269        return new NoteImportMetadata(
 82270            importKey,
 82271            normalizedSourceId,
 82272            normalizedHeadingPath,
 82273            occurrenceIndex,
 82274            sectionOrderIndex,
 82275            lastImportedBodyHash.ToLowerInvariant());
 76    }
 77
 78    public static NoteImportMetadata Rehydrate(
 79        string importKey,
 80        string sourceFileId,
 81        string headingPath,
 82        int occurrenceIndex,
 83        int sectionOrderIndex,
 84        string lastImportedBodyHash) =>
 82285        new(importKey, sourceFileId, headingPath, occurrenceIndex, sectionOrderIndex, lastImportedBodyHash);
 86
 87    public NoteImportMetadata WithUpdatedImportState(int sectionOrderIndex, string newImportedBodyHash) =>
 888        Create(SourceFileId, HeadingPath, OccurrenceIndex, sectionOrderIndex, newImportedBodyHash);
 89}