< 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@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
11%
Covered lines: 1
Uncovered lines: 8
Coverable lines: 9
Total lines: 46
Line coverage: 11.1%
Branch coverage
0%
Covered branches: 0
Total branches: 6
Branch coverage: 0%
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@c33ec02a85e4f8d6061aeaab5a5e8c3a8b665594 10/15/2025 - 21:27:26 Line coverage: 11.1% (1/9) Branch coverage: 0% (0/6) Total lines: 46 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b665594

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
get_ConnectedCount()100%210%
OnConnected(...)0%620%
OnDisconnected(...)0%620%
GetConnections()0%620%

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{
 110    private readonly ConcurrentDictionary<string, byte> _connections = new();
 11
 12    /// <summary>
 13    /// Gets the current number of connected clients.
 14    /// </summary>
 015    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    {
 023        if (!string.IsNullOrEmpty(connectionId))
 24        {
 025            _connections[connectionId] = 1;
 26        }
 027    }
 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    {
 035        if (!string.IsNullOrEmpty(connectionId))
 36        {
 037            _ = _connections.TryRemove(connectionId, out _);
 38        }
 039    }
 40
 41    /// <summary>
 42    /// Returns a snapshot of current connection identifiers.
 43    /// </summary>
 44    /// <returns>A read-only collection of connection IDs.</returns>
 045    public IReadOnlyCollection<string> GetConnections() => _connections.Keys as IReadOnlyCollection<string> ?? [.. _conn
 46}