< Summary

Information
Class: Services.BitrixStockServices.BitrixStockActiveStageStore
Assembly: Services
File(s): /home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockActiveStageStore.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 20
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%
Set(...)100%11100%
Clear(...)100%11100%
Get(...)100%22100%
GetAnyActiveReportId()100%44100%

File(s)

/home/runner/work/Studio2Prod/Studio2Prod/AppRepository/BitrixStockServices/BitrixStockActiveStageStore.cs

#LineLine coverage
 1using System.Collections.Concurrent;
 2
 3namespace Services.BitrixStockServices;
 4
 5/// <summary>
 6/// Singleton-хранилище активного этапа для каждого reportId.
 7/// Позволяет ListSyncReports возвращать текущий этап фоновой задачи.
 8/// </summary>
 9public class BitrixStockActiveStageStore
 10{
 3011    private readonly ConcurrentDictionary<string, int> _stages = new(StringComparer.Ordinal);
 12
 10313    public void Set(string reportId, int stage)   => _stages[reportId] = stage;
 2014    public void Clear(string reportId)            => _stages.TryRemove(reportId, out _);
 3315    public int  Get(string reportId)              => _stages.TryGetValue(reportId, out var s) ? s : 0;
 16
 17    /// <summary>Первый reportId с активным этапом (1–5), или null.</summary>
 18    public string? GetAnyActiveReportId() =>
 2319        _stages.FirstOrDefault(kv => kv.Value > 0).Key is { Length: > 0 } k ? k : null;
 20}