< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Protocol.ValueObjects.BigSize
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/ValueObjects/BigSize.cs
Tag: 36_15743069263
Line coverage
75%
Covered lines: 30
Uncovered lines: 10
Coverable lines: 40
Total lines: 148
Line coverage: 75%
Branch coverage
75%
Covered branches: 15
Total branches: 20
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Value()100%11100%
op_Implicit(...)100%11100%
op_Implicit(...)100%210%
op_Implicit(...)100%22100%
op_Implicit(...)50%2.15266.67%
op_Implicit(...)100%22100%
op_Implicit(...)100%210%
op_Implicit(...)100%22100%
op_Implicit(...)50%2.15266.67%
op_Implicit(...)100%22100%
op_Implicit(...)100%210%
op_Implicit(...)100%22100%
op_Implicit(...)0%620%
op_Implicit(...)100%22100%
op_Implicit(...)100%210%
CompareTo(...)50%2.15266.67%
op_LessThan(...)100%11100%
op_GreaterThan(...)100%11100%
op_LessThanOrEqual(...)100%11100%
op_GreaterThanOrEqual(...)100%11100%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Protocol/ValueObjects/BigSize.cs

#LineLine coverage
 1namespace NLightning.Domain.Protocol.ValueObjects;
 2
 3using Domain.Interfaces;
 4
 5/// <summary>
 6/// Represents a variable length integer.
 7/// </summary>
 8/// <param name="value">The value of the big size.</param>
 9/// <remarks>
 10/// Initializes a new instance of the <see cref="BigSize"/> struct.
 11/// </remarks>
 272412public readonly record struct BigSize(ulong Value) : IValueObject, IComparable
 13{
 14    #region Implicit Conversions
 15
 2816    public static implicit operator ulong(BigSize bigSize) => bigSize.Value;
 017    public static implicit operator BigSize(ulong value) => new(value);
 18
 19    public static implicit operator long(BigSize bigSize)
 20    {
 2821        if (bigSize.Value > long.MaxValue)
 22        {
 423            throw new OverflowException($"Cannot convert {bigSize.Value} to long because it's too large.");
 24        }
 25
 2426        return (long)bigSize.Value;
 27    }
 28
 29    public static implicit operator BigSize(long value)
 30    {
 1631        if (value < 0)
 32        {
 033            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 34        }
 35
 1636        return new BigSize((ulong)value);
 37    }
 38
 39    public static implicit operator uint(BigSize bigSize)
 40    {
 3641        if (bigSize.Value > uint.MaxValue)
 42        {
 843            throw new OverflowException($"Cannot convert {bigSize.Value} to uint because it's too large.");
 44        }
 45
 2846        return (uint)bigSize.Value;
 47    }
 48
 049    public static implicit operator BigSize(uint value) => new(value);
 50
 51    public static implicit operator int(BigSize bigSize)
 52    {
 34053        if (bigSize.Value > int.MaxValue)
 54        {
 1255            throw new OverflowException($"Cannot convert {bigSize.Value} to int because it's too large.");
 56        }
 57
 32858        return (int)bigSize.Value;
 59    }
 60
 61    public static implicit operator BigSize(int value)
 62    {
 98063        if (value < 0)
 64        {
 065            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 66        }
 67
 98068        return new BigSize((ulong)value);
 69    }
 70
 71    public static implicit operator ushort(BigSize bigSize)
 72    {
 3673        if (bigSize.Value > ushort.MaxValue)
 74        {
 1675            throw new OverflowException($"Cannot convert {bigSize.Value} to ushort because it's too large.");
 76        }
 77
 2078        return (ushort)bigSize.Value;
 79    }
 80
 081    public static implicit operator BigSize(ushort value) => new(value);
 82
 83    public static implicit operator short(BigSize bigSize)
 84    {
 2885        if (bigSize.Value > (ulong)short.MaxValue)
 86        {
 2087            throw new OverflowException($"Cannot convert {bigSize.Value} to short because it's too large.");
 88        }
 89
 890        return (short)bigSize.Value;
 91    }
 92
 93    public static implicit operator BigSize(short value)
 94    {
 095        if (value < 0)
 96        {
 097            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 98        }
 99
 0100        return new BigSize((ulong)value);
 101    }
 102
 103    public static implicit operator byte(BigSize bigSize)
 104    {
 180105        if (bigSize.Value > byte.MaxValue)
 106        {
 24107            throw new OverflowException($"Cannot convert {bigSize.Value} to byte because it's too large.");
 108        }
 109
 156110        return (byte)bigSize.Value;
 111    }
 112
 0113    public static implicit operator BigSize(byte value) => new(value);
 114
 115    #endregion
 116
 117    #region Equality
 118
 119    public int CompareTo(object? obj)
 120    {
 340121        if (obj is not BigSize bigSize)
 0122            throw new ArgumentException("Object is not a BigSize");
 123
 340124        return Value.CompareTo(bigSize.Value);
 125    }
 126
 127    public static bool operator <(BigSize left, BigSize right)
 128    {
 248129        return left.Value < right.Value;
 130    }
 131
 132    public static bool operator >(BigSize left, BigSize right)
 133    {
 16134        return left.Value > right.Value;
 135    }
 136
 137    public static bool operator <=(BigSize left, BigSize right)
 138    {
 16139        return left.Value <= right.Value;
 140    }
 141
 142    public static bool operator >=(BigSize left, BigSize right)
 143    {
 16144        return left.Value >= right.Value;
 145    }
 146
 147    #endregion
 148}