< Summary

Information
Class: Elsa.ExternalAuthentication.Services.DefaultExternalAuthenticationAdapterRegistry
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/DefaultExternalAuthenticationAdapterRegistry.cs
Line coverage
93%
Covered lines: 15
Uncovered lines: 1
Coverable lines: 16
Total lines: 35
Line coverage: 93.7%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%1192.85%
ListDescriptors()100%11100%
TryGet(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Services/DefaultExternalAuthenticationAdapterRegistry.cs

#LineLine coverage
 1using Elsa.ExternalAuthentication.Contracts;
 2using Elsa.ExternalAuthentication.Models;
 3using Elsa.ExternalAuthentication.Options;
 4using Microsoft.Extensions.Options;
 5
 6namespace Elsa.ExternalAuthentication.Services;
 7
 8/// <summary>
 9/// Provides the startup-installed adapter catalog without coupling callers to a concrete adapter.
 10/// </summary>
 11public sealed class DefaultExternalAuthenticationAdapterRegistry : IExternalAuthenticationAdapterRegistry
 12{
 13    private readonly IReadOnlyDictionary<string, IExternalAuthenticationAdapter> _adapters;
 14    private readonly IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor> _descriptors;
 15
 516    public DefaultExternalAuthenticationAdapterRegistry(
 517        IEnumerable<IExternalAuthenticationAdapter> adapters,
 518        ExtensionDescriptorValidator descriptorValidator,
 519        IOptions<ExternalAuthenticationOptions> options)
 20    {
 521        _adapters = ExtensionRegistryBuilder.Create(
 522            adapters,
 623            adapter => adapter.Type,
 524            options.Value.AllowedAdapterTypes,
 525            "adapter");
 426        _descriptors = _adapters.Values
 427            .Select(descriptorValidator.Validate)
 028            .OrderBy(x => x.Type, StringComparer.Ordinal)
 429            .ToArray();
 430    }
 31
 132    public IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor> ListDescriptors() => _descriptors;
 33
 734    public bool TryGet(string type, out IExternalAuthenticationAdapter adapter) => _adapters.TryGetValue(type, out adapt
 35}