< Summary

Information
Class: Elsa.Identity.Models.RoleFilter
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Models/RoleFilter.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_Ids()100%11100%
get_TenantId()100%11100%
Apply(...)100%66100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Models/RoleFilter.cs

#LineLine coverage
 1using Elsa.Common.Multitenancy;
 2using Elsa.Identity.Entities;
 3
 4namespace Elsa.Identity.Models;
 5
 6/// <summary>
 7/// Represents a role filter.
 8/// </summary>
 9public class RoleFilter
 10{
 11    /// <summary>
 12    /// Gets or sets the role ID to filter for.
 13    /// </summary>
 22114    public string? Id { get; set; }
 15
 16    /// <summary>
 17    /// Gets or sets the role IDs to filter for.
 18    /// </summary>
 8819    public ICollection<string>? Ids { get; set; }
 20
 21    /// <summary>
 22    /// Gets or sets the tenant to filter for. The tenant-agnostic sentinel is always included, matching
 23    /// the Entity Framework query filter, so a shared platform role remains visible from every tenant.
 24    /// Legacy records without a tenant remain visible to the default tenant for backwards compatibility.
 25    /// </summary>
 9126    public string? TenantId { get; set; }
 27
 28    /// <summary>
 29    /// Applies the filter to the specified queryable.
 30    /// </summary>
 31    /// <param name="queryable">The queryable.</param>
 32    /// <returns>The filtered queryable.</returns>
 33    public IQueryable<Role> Apply(IQueryable<Role> queryable)
 34    {
 8335        var filter = this;
 15636        if (filter.Id != null) queryable = queryable.Where(x => x.Id == filter.Id);
 8637        if (filter.Ids != null) queryable = queryable.Where(x => filter.Ids.Contains(x.Id));
 8338        if (filter.TenantId != null)
 439            queryable = queryable.Where(x => x.TenantId == filter.TenantId || x.TenantId == Tenant.AgnosticTenantId || (
 40
 8341        return queryable;
 42    }
 43}