< Summary

Information
Class: NostrSure.Domain.Entities.NostrTag
Assembly: NostrSure.Domain
File(s): /home/runner/work/NostrSure/NostrSure/NostrSure.Domain/Entities/NostrTag.cs
Line coverage
94%
Covered lines: 18
Uncovered lines: 1
Coverable lines: 19
Total lines: 33
Line coverage: 94.7%
Branch coverage
72%
Covered branches: 13
Total branches: 18
Branch coverage: 72.2%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Name()100%11100%
get_Values()100%11100%
.ctor(...)66.66%66100%
FromArray(...)50%4480%
IsValid()87.5%88100%

File(s)

/home/runner/work/NostrSure/NostrSure/NostrSure.Domain/Entities/NostrTag.cs

#LineLine coverage
 1namespace NostrSure.Domain.Entities;
 2
 3public sealed class NostrTag
 4{
 1405    public string Name { get; }
 2026    public IReadOnlyList<string> Values { get; }
 7
 968    public NostrTag(string name, IEnumerable<string> values)
 969    {
 9610        if (string.IsNullOrWhiteSpace(name))
 111            throw new ArgumentException("Tag name must not be empty", nameof(name));
 9512        Name = name.ToLowerInvariant();
 9513        Values = values?.ToList() ?? throw new ArgumentNullException(nameof(values));
 9514    }
 15
 16    public static NostrTag FromArray(IReadOnlyList<string> arr)
 2617    {
 2618        if (arr == null || arr.Count == 0)
 019            throw new ArgumentException("Tag array must have at least one element");
 2620        return new NostrTag(arr[0], arr.Skip(1));
 2621    }
 22
 23    // Optional: Validate known tag types
 24    public bool IsValid()
 2025    {
 26        // Example: "p" and "e" tags must have a second element that is a 64-char hex string
 2027        if ((Name == "p" || Name == "e") && (Values.Count < 1 || Values[0].Length != 64))
 628            return false;
 29        // Add more rules as needed
 1430        return true;
 2031    }
 32}
 33