< Summary

Information
Class: Elsa.Identity.Providers.ConfigurationBasedRoleProvider
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Providers/ConfigurationBasedRoleProvider.cs
Line coverage
50%
Covered lines: 3
Uncovered lines: 3
Coverable lines: 6
Total lines: 33
Line coverage: 50%
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%11100%
FindManyAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Providers/ConfigurationBasedRoleProvider.cs

#LineLine coverage
 1using Elsa.Identity.Contracts;
 2using Elsa.Identity.Entities;
 3using Elsa.Identity.Models;
 4using Elsa.Identity.Options;
 5using JetBrains.Annotations;
 6using Microsoft.Extensions.Options;
 7
 8namespace Elsa.Identity.Providers;
 9
 10/// <summary>
 11/// Represents a provider of roles that uses <see cref="RolesOptions"/>.
 12/// </summary>
 13[PublicAPI]
 14public class ConfigurationBasedRoleProvider : IRoleProvider
 15{
 16    private readonly IOptions<RolesOptions> _options;
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="ConfigurationBasedRoleProvider"/> class.
 20    /// </summary>
 121    public ConfigurationBasedRoleProvider(IOptions<RolesOptions> options)
 22    {
 123        _options = options;
 124    }
 25
 26    /// <inheritdoc />
 27    public ValueTask<IEnumerable<Role>> FindManyAsync(RoleFilter filter, CancellationToken cancellationToken = default)
 28    {
 029        var rolesQueryable = _options.Value.Roles.AsQueryable();
 030        var roles = filter.Apply(rolesQueryable).ToList();
 031        return new(roles);
 32    }
 33}