< Summary

Information
Class: RoleRadar.Domain.Audit.AuditContentSummary
Assembly: RoleRadar.Domain
File(s): /home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Audit/AuditContentSummary.cs
Line coverage
88%
Covered lines: 22
Uncovered lines: 3
Coverable lines: 25
Total lines: 54
Line coverage: 88%
Branch coverage
60%
Covered branches: 6
Total branches: 10
Branch coverage: 60%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_BodyHash()100%11100%
get_ByteLength()100%11100%
get_Status()100%11100%
get_Excerpt()100%11100%
.ctor(...)50%9876.92%
FromNote(...)100%22100%

File(s)

/home/runner/work/roleradar/roleradar/src/RoleRadar.Domain/Audit/AuditContentSummary.cs

#LineLine coverage
 1using System.Text;
 2using RoleRadar.Domain.Notes;
 3
 4namespace RoleRadar.Domain.Audit;
 5
 6public sealed record AuditContentSummary
 7{
 8    public const int MaxExcerptChars = 200;
 9
 106610    public string BodyHash { get; }
 11
 106612    public int ByteLength { get; }
 13
 106614    public string Status { get; }
 15
 106616    public string Excerpt { get; }
 17
 157018    public AuditContentSummary(string bodyHash, int byteLength, string status, string excerpt)
 19    {
 157020        if (string.IsNullOrWhiteSpace(bodyHash))
 21        {
 022            throw new ArgumentException("Body hash is required.", nameof(bodyHash));
 23        }
 24
 157025        if (byteLength < 0)
 26        {
 027            throw new ArgumentOutOfRangeException(nameof(byteLength), "Byte length cannot be negative.");
 28        }
 29
 157030        if (string.IsNullOrWhiteSpace(status))
 31        {
 032            throw new ArgumentException("Status is required.", nameof(status));
 33        }
 34
 157035        ArgumentNullException.ThrowIfNull(excerpt);
 36
 157037        BodyHash = bodyHash;
 157038        ByteLength = byteLength;
 157039        Status = status;
 157040        Excerpt = excerpt.Length <= MaxExcerptChars ? excerpt : excerpt[..MaxExcerptChars];
 157041    }
 42
 43    public static AuditContentSummary FromNote(Note note)
 44    {
 141645        ArgumentNullException.ThrowIfNull(note);
 141646        var byteLength = Encoding.UTF8.GetByteCount(note.Body);
 141647        var excerpt = note.Body.Length <= MaxExcerptChars ? note.Body : note.Body[..MaxExcerptChars];
 141648        return new AuditContentSummary(
 141649            note.CurrentBodyHash,
 141650            byteLength,
 141651            note.Status.ToWireString(),
 141652            excerpt);
 53    }
 54}