< Summary

Information
Class: Chronicis.Api.Services.ExternalLinks.ExternalLinkProviderRegistry
Assembly: Chronicis.Api
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/ExternalLinks/ExternalLinkProviderRegistry.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 28
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
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%210%
GetProvider(...)0%2040%
GetAllProviders()100%210%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Api/Services/ExternalLinks/ExternalLinkProviderRegistry.cs

#LineLine coverage
 1namespace Chronicis.Api.Services.ExternalLinks;
 2
 3public class ExternalLinkProviderRegistry : IExternalLinkProviderRegistry
 4{
 5    private readonly Dictionary<string, IExternalLinkProvider> _providers;
 6
 07    public ExternalLinkProviderRegistry(IEnumerable<IExternalLinkProvider> providers)
 8    {
 09        _providers = providers
 010            .GroupBy(p => p.Key, StringComparer.OrdinalIgnoreCase)
 011            .ToDictionary(g => g.Key, g => g.First(), StringComparer.OrdinalIgnoreCase);
 012    }
 13
 14    public IExternalLinkProvider? GetProvider(string key)
 15    {
 016        if (string.IsNullOrWhiteSpace(key))
 17        {
 018            return null;
 19        }
 20
 021        return _providers.TryGetValue(key, out var provider) ? provider : null;
 22    }
 23
 24    public IReadOnlyList<IExternalLinkProvider> GetAllProviders()
 25    {
 026        return _providers.Values.ToList();
 27    }
 28}