< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Crypto.ValueObjects.Secret
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Crypto/ValueObjects/Secret.cs
Tag: 36_15743069263
Line coverage
61%
Covered lines: 8
Uncovered lines: 5
Coverable lines: 13
Total lines: 40
Line coverage: 61.5%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Empty()100%11100%
.ctor(...)50%2.26260%
op_Implicit(...)100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%210%
op_Implicit(...)100%11100%
Equals(...)100%11100%
Equals(...)0%620%
GetHashCode()100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Crypto/ValueObjects/Secret.cs

#LineLine coverage
 1namespace NLightning.Domain.Crypto.ValueObjects;
 2
 3using Constants;
 4using Utils.Extensions;
 5
 6public readonly struct Secret : IEquatable<Secret>
 7{
 8    private readonly byte[] _value;
 649    public static Secret Empty => new(new byte[CryptoConstants.SecretLen]);
 10
 11    public Secret(byte[] value)
 12    {
 96013        if (value.Length < CryptoConstants.SecretLen)
 014            throw new ArgumentOutOfRangeException(nameof(value), value.Length,
 015                                                  $"Hash must have {CryptoConstants.SecretLen} bytes.");
 16
 96017        _value = value;
 96018    }
 19
 81620    public static implicit operator Secret(byte[] bytes) => new(bytes);
 71221    public static implicit operator byte[](Secret hash) => hash._value;
 22
 023    public static implicit operator ReadOnlyMemory<byte>(Secret hash) => hash._value;
 448824    public static implicit operator ReadOnlySpan<byte>(Secret hash) => hash._value;
 25
 26    public bool Equals(Secret other)
 27    {
 7628        return _value.SequenceEqual(other._value);
 29    }
 30
 31    public override bool Equals(object? obj)
 32    {
 033        return obj is Secret other && Equals(other);
 34    }
 35
 36    public override int GetHashCode()
 37    {
 038        return _value.GetByteArrayHashCode();
 39    }
 40}