< Summary - Kestrun — Combined Coverage

Information
Class: Kestrun.SignalR.InMemoryConnectionTracker
Assembly: Kestrun
File(s): /home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/SignalR/InMemoryConnectionTracker.cs
Tag: Kestrun/Kestrun@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 46
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 10/15/2025 - 21:27:26 Line coverage: 11.1% (1/9) Branch coverage: 0% (0/6) Total lines: 46 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b66559412/15/2025 - 18:44:50 Line coverage: 100% (9/9) Branch coverage: 83.3% (5/6) Total lines: 46 Tag: Kestrun/Kestrun@6b9e56ea2de904fc3597033ef0f9bc7839d5d618 10/15/2025 - 21:27:26 Line coverage: 11.1% (1/9) Branch coverage: 0% (0/6) Total lines: 46 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b66559412/15/2025 - 18:44:50 Line coverage: 100% (9/9) Branch coverage: 83.3% (5/6) Total lines: 46 Tag: Kestrun/Kestrun@6b9e56ea2de904fc3597033ef0f9bc7839d5d618

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_ConnectedCount()100%11100%
OnConnected(...)100%22100%
OnDisconnected(...)100%22100%
GetConnections()50%22100%

File(s)

/home/runner/work/Kestrun/Kestrun/src/CSharp/Kestrun/SignalR/InMemoryConnectionTracker.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2
 3namespace Kestrun.SignalR;
 4
 5/// <summary>
 6/// In-memory thread-safe implementation of <see cref="IConnectionTracker"/>.
 7/// </summary>
 8public sealed class InMemoryConnectionTracker : IConnectionTracker
 9{
 2110    private readonly ConcurrentDictionary<string, byte> _connections = new();
 11
 12    /// <summary>
 13    /// Gets the current number of connected clients.
 14    /// </summary>
 2215    public int ConnectedCount => _connections.Count;
 16
 17    /// <summary>
 18    /// Records a new connection.
 19    /// </summary>
 20    /// <param name="connectionId">The ID of the connection.</param>
 21    public void OnConnected(string connectionId)
 22    {
 17623        if (!string.IsNullOrEmpty(connectionId))
 24        {
 17425            _connections[connectionId] = 1;
 26        }
 17627    }
 28
 29    /// <summary>
 30    /// Records a disconnection.
 31    /// </summary>
 32    /// <param name="connectionId">The ID of the connection.</param>
 33    public void OnDisconnected(string connectionId)
 34    {
 3535        if (!string.IsNullOrEmpty(connectionId))
 36        {
 3337            _ = _connections.TryRemove(connectionId, out _);
 38        }
 3539    }
 40
 41    /// <summary>
 42    /// Returns a snapshot of current connection identifiers.
 43    /// </summary>
 44    /// <returns>A read-only collection of connection IDs.</returns>
 1045    public IReadOnlyCollection<string> GetConnections() => _connections.Keys as IReadOnlyCollection<string> ?? [.. _conn
 46}