< Summary - Combined Code Coverage

Information
Class: NLightning.Domain.Models.RoutingInfoCollection
Assembly: NLightning.Domain
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Domain/Models/RoutingInfoCollection.cs
Tag: 30_15166811759
Line coverage
76%
Covered lines: 20
Uncovered lines: 6
Coverable lines: 26
Total lines: 88
Line coverage: 76.9%
Branch coverage
100%
Covered branches: 10
Total branches: 10
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Add(...)100%22100%
AddRange(...)100%22100%
Remove(...)100%22100%
RemoveAt(...)100%210%
RemoveAll(...)100%22100%
RemoveRange(...)100%210%
OnChanged()100%22100%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Domain/Models/RoutingInfoCollection.cs

#LineLine coverage
 1namespace NLightning.Domain.Models;
 2
 3/// <summary>
 4/// A collection of routing information
 5/// </summary>
 6public sealed class RoutingInfoCollection : List<RoutingInfo>
 7{
 8    /// <summary>
 9    /// Te maximum amount of routing information that can be stored in a single routing information list
 10    /// </summary>
 11    /// <remarks>
 12    /// The maximum length of a tagged field is 1023 * 5 bits. The routing information is 408 bits long.
 13    /// 1023 * 5 bits = 5115 bits / 408 bits = 12.5 => round down to 12
 14    /// </remarks>
 15    private const int MAX_CAPACITY = 12;
 16
 17    public event EventHandler? Changed;
 18
 19    /// <summary>
 20    /// Adds a routing information to the collection
 21    /// </summary>
 22    /// <param name="routingInfo">The routing information to add</param>
 23    /// <exception cref="InvalidOperationException">Thrown when the maximum capacity has been reached</exception>
 24    /// <remarks>
 25    /// The maximum capacity of the collection is 12
 26    /// </remarks>
 27    public new void Add(RoutingInfo routingInfo)
 28    {
 19229        if (Count >= MAX_CAPACITY)
 30        {
 431            throw new InvalidOperationException($"The maximum capacity of {MAX_CAPACITY} has been reached");
 32        }
 33
 18834        base.Add(routingInfo);
 35
 18836        OnChanged();
 18837    }
 38
 39    public new void AddRange(IEnumerable<RoutingInfo> routingInfos)
 40    {
 841        var iEnumerable = routingInfos.ToList();
 842        if (Count + iEnumerable.Count > MAX_CAPACITY)
 43        {
 444            throw new InvalidOperationException($"The maximum capacity of {MAX_CAPACITY} has been reached");
 45        }
 46
 447        base.AddRange(iEnumerable);
 448    }
 49
 50    public new bool Remove(RoutingInfo item)
 51    {
 852        if (!base.Remove(item))
 53        {
 454            return false;
 55        }
 56
 457        OnChanged();
 458        return true;
 59    }
 60
 61    internal new void RemoveAt(int index)
 62    {
 063        base.RemoveAt(index);
 064        OnChanged();
 065    }
 66
 67    public new int RemoveAll(Predicate<RoutingInfo> match)
 68    {
 469        var removed = base.RemoveAll(match);
 470        if (removed > 0)
 71        {
 472            OnChanged();
 73        }
 74
 475        return removed;
 76    }
 77
 78    internal new void RemoveRange(int index, int count)
 79    {
 080        base.RemoveRange(index, count);
 081        OnChanged();
 082    }
 83
 84    private void OnChanged()
 85    {
 19686        Changed?.Invoke(this, EventArgs.Empty);
 6087    }
 88}