< Summary

Information
Class: Elsa.Resilience.ResilienceStrategyCatalog
Assembly: Elsa.Resilience.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience.Core/Services/ResilienceStrategyCatalog.cs
Line coverage
33%
Covered lines: 4
Uncovered lines: 8
Coverable lines: 12
Total lines: 31
Line coverage: 33.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
ListAsync(...)100%210%
GetAsync()100%210%
GetStrategiesInternalAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience.Core/Services/ResilienceStrategyCatalog.cs

#LineLine coverage
 1namespace Elsa.Resilience;
 2
 3public class ResilienceStrategyCatalog : IResilienceStrategyCatalog
 4{
 5    private readonly Lazy<Task<IEnumerable<IResilienceStrategy>>> _strategies;
 6    private readonly IEnumerable<IResilienceStrategySource> _providers;
 7
 18    public ResilienceStrategyCatalog(IEnumerable<IResilienceStrategySource> providers)
 9    {
 110        _providers = providers;
 111        _strategies = new(GetStrategiesInternalAsync, LazyThreadSafetyMode.ExecutionAndPublication);
 112    }
 13
 14    public Task<IEnumerable<IResilienceStrategy>> ListAsync(CancellationToken cancellationToken = default)
 15    {
 016        return _strategies.Value;
 17    }
 18
 19    public async Task<IResilienceStrategy?> GetAsync(string id, CancellationToken cancellationToken = default)
 20    {
 021        var strategies = await ListAsync(cancellationToken);
 022        return strategies.FirstOrDefault(x => x.Id == id);
 023    }
 24
 25    private async Task<IEnumerable<IResilienceStrategy>> GetStrategiesInternalAsync()
 26    {
 027        var strategies = new List<IResilienceStrategy>();
 028        foreach (var provider in _providers) strategies.AddRange(await provider.GetStrategiesAsync());
 029        return strategies;
 030    }
 31}