< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.ValueObjects.BigSize
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/ValueObjects/BigSize.cs
Tag: 30_15166811759
Line coverage
77%
Covered lines: 35
Uncovered lines: 10
Coverable lines: 45
Total lines: 162
Line coverage: 77.7%
Branch coverage
72%
Covered branches: 16
Total branches: 22
Branch coverage: 72.7%
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%
Equals(...)50%22100%
Equals(...)100%11100%
GetHashCode()100%11100%
CompareTo(...)50%2.15266.67%
op_Equality(...)100%11100%
op_Inequality(...)100%11100%
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/ValueObjects/BigSize.cs

#LineLine coverage
 1namespace NLightning.Domain.ValueObjects;
 2
 3using 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>
 12public readonly struct BigSize(ulong value) : IValueObject, IComparable, IEquatable<BigSize>
 13{
 14    /// <summary>
 15    /// The uint representation of the big size.
 16    /// </summary>
 543617    public ulong Value { get; } = value;
 18
 19    #region Implicit Conversions
 2820    public static implicit operator ulong(BigSize bigSize) => bigSize.Value;
 021    public static implicit operator BigSize(ulong value) => new(value);
 22
 23    public static implicit operator long(BigSize bigSize)
 24    {
 2825        if (bigSize.Value > long.MaxValue)
 26        {
 427            throw new OverflowException($"Cannot convert {bigSize.Value} to long because it's too large.");
 28        }
 29
 2430        return (long)bigSize.Value;
 31    }
 32    public static implicit operator BigSize(long value)
 33    {
 1634        if (value < 0)
 35        {
 036            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 37        }
 38
 1639        return new BigSize((ulong)value);
 40    }
 41
 42    public static implicit operator uint(BigSize bigSize)
 43    {
 3644        if (bigSize.Value > uint.MaxValue)
 45        {
 846            throw new OverflowException($"Cannot convert {bigSize.Value} to uint because it's too large.");
 47        }
 2848        return (uint)bigSize.Value;
 49    }
 050    public static implicit operator BigSize(uint value) => new(value);
 51
 52    public static implicit operator int(BigSize bigSize)
 53    {
 34054        if (bigSize.Value > int.MaxValue)
 55        {
 1256            throw new OverflowException($"Cannot convert {bigSize.Value} to int because it's too large.");
 57        }
 32858        return (int)bigSize.Value;
 59    }
 60    public static implicit operator BigSize(int value)
 61    {
 104062        if (value < 0)
 63        {
 064            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 65        }
 104066        return new BigSize((ulong)value);
 67    }
 68
 69    public static implicit operator ushort(BigSize bigSize)
 70    {
 3671        if (bigSize.Value > ushort.MaxValue)
 72        {
 1673            throw new OverflowException($"Cannot convert {bigSize.Value} to ushort because it's too large.");
 74        }
 2075        return (ushort)bigSize.Value;
 76    }
 077    public static implicit operator BigSize(ushort value) => new(value);
 78
 79    public static implicit operator short(BigSize bigSize)
 80    {
 2881        if (bigSize.Value > (ulong)short.MaxValue)
 82        {
 2083            throw new OverflowException($"Cannot convert {bigSize.Value} to short because it's too large.");
 84        }
 885        return (short)bigSize.Value;
 86    }
 87    public static implicit operator BigSize(short value)
 88    {
 089        if (value < 0)
 90        {
 091            throw new OverflowException($"Cannot convert {value} to BigSize because it's negative.");
 92        }
 093        return new BigSize((ulong)value);
 94    }
 95
 96    public static implicit operator byte(BigSize bigSize)
 97    {
 18098        if (bigSize.Value > byte.MaxValue)
 99        {
 24100            throw new OverflowException($"Cannot convert {bigSize.Value} to byte because it's too large.");
 101        }
 156102        return (byte)bigSize.Value;
 103    }
 0104    public static implicit operator BigSize(byte value) => new(value);
 105    #endregion
 106
 107    #region Equality
 108    public override bool Equals(object? obj)
 109    {
 8110        return obj is BigSize bigSize && Value == bigSize.Value;
 111    }
 112    public bool Equals(BigSize other)
 113    {
 240114        return Value == other.Value;
 115    }
 116
 117    public override int GetHashCode()
 118    {
 4119        return Value.GetHashCode();
 120    }
 121
 122    public int CompareTo(object? obj)
 123    {
 348124        if (obj is not BigSize bigSize)
 125        {
 0126            throw new ArgumentException("Object is not a BigSize");
 127        }
 128
 348129        return Value.CompareTo(bigSize.Value);
 130    }
 131
 132    public static bool operator ==(BigSize left, BigSize right)
 133    {
 216134        return left.Value == right.Value;
 135    }
 136
 137    public static bool operator !=(BigSize left, BigSize right)
 138    {
 160139        return !(left == right);
 140    }
 141
 142    public static bool operator <(BigSize left, BigSize right)
 143    {
 248144        return left.Value < right.Value;
 145    }
 146
 147    public static bool operator >(BigSize left, BigSize right)
 148    {
 16149        return left.Value > right.Value;
 150    }
 151
 152    public static bool operator <=(BigSize left, BigSize right)
 153    {
 16154        return left.Value <= right.Value;
 155    }
 156
 157    public static bool operator >=(BigSize left, BigSize right)
 158    {
 16159        return left.Value >= right.Value;
 160    }
 161    #endregion
 162}