< 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
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 28
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%
GetProvider(...)100%44100%
GetAllProviders()100%11100%

File(s)

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

#LineLine coverage
 1namespace Chronicis.Api.Services.ExternalLinks;
 2
 3public sealed class ExternalLinkProviderRegistry : IExternalLinkProviderRegistry
 4{
 5    private readonly Dictionary<string, IExternalLinkProvider> _providers;
 6
 7    public ExternalLinkProviderRegistry(IEnumerable<IExternalLinkProvider> providers)
 8    {
 59        _providers = providers
 510            .GroupBy(p => p.Key, StringComparer.OrdinalIgnoreCase)
 511            .ToDictionary(g => g.Key, g => g.First(), StringComparer.OrdinalIgnoreCase);
 512    }
 13
 14    public IExternalLinkProvider? GetProvider(string key)
 15    {
 616        if (string.IsNullOrWhiteSpace(key))
 17        {
 318            return null;
 19        }
 20
 321        return _providers.TryGetValue(key, out var provider) ? provider : null;
 22    }
 23
 24    public IReadOnlyList<IExternalLinkProvider> GetAllProviders()
 25    {
 226        return _providers.Values.ToList();
 27    }
 28}