< Summary

Information
Class: Elsa.Workflows.Runtime.Filters.TriggerFilter
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/TriggerFilter.cs
Line coverage
100%
Covered lines: 24
Uncovered lines: 0
Coverable lines: 24
Total lines: 81
Line coverage: 100%
Branch coverage
77%
Covered branches: 14
Total branches: 18
Branch coverage: 77.7%
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_WorkflowDefinitionId()100%11100%
get_WorkflowDefinitionVersionId()100%11100%
get_WorkflowDefinitionIds()100%11100%
get_WorkflowDefinitionVersionIds()100%11100%
get_Name()100%11100%
get_Names()100%11100%
get_Hash()100%11100%
get_TenantAgnostic()100%11100%
Apply(...)77.77%1818100%
ByNames(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Filters/TriggerFilter.cs

#LineLine coverage
 1using Elsa.Workflows.Runtime.Entities;
 2
 3namespace Elsa.Workflows.Runtime.Filters;
 4
 5/// <summary>
 6/// Represents a filter for triggers.
 7/// </summary>
 8public class TriggerFilter
 9{
 10    /// <summary>
 11    /// Gets or sets the ID of the trigger to find.
 12    /// </summary>
 281013    public string? Id { get; set; }
 14
 15    /// <summary>
 16    /// Gets or sets the IDs of the triggers to find.
 17    /// </summary>
 284218    public ICollection<string>? Ids { get; set; }
 19
 20    /// <summary>
 21    /// Gets or sets the ID of the workflow definition.
 22    /// </summary>
 523223    public string? WorkflowDefinitionId { get; set; }
 24
 25    /// <summary>
 26    /// Gets or sets the ID of the workflow definition version.
 27    /// </summary>
 281028    public string? WorkflowDefinitionVersionId { get; set; }
 29
 30    /// <summary>
 31    /// Gets or sets the IDs of the workflow definitions.
 32    /// </summary>
 281033    public ICollection<string>? WorkflowDefinitionIds { get; set; }
 34
 35    /// <summary>
 36    /// Gets or sets the IDs of the workflow definition versions.
 37    /// </summary>
 281038    public ICollection<string>? WorkflowDefinitionVersionIds { get; set; }
 39
 40    /// <summary>
 41    /// Gets or sets the name of the trigger to find.
 42    /// </summary>
 283843    public string? Name { get; set; }
 44
 45    /// <summary>
 46    /// Gets or sets the names of the triggers to find.
 47    /// </summary>
 283848    public ICollection<string>? Names { get; set; }
 49
 50    /// <summary>
 51    /// Gets or sets the hash of the trigger to find.
 52    /// </summary>
 313553    public string? Hash { get; set; }
 54
 55    /// <summary>
 56    /// Get or sets if the triggers to find is a tenant agnostic search
 57    /// </summary>
 262958    public bool TenantAgnostic { get; set; }
 59
 60    /// <summary>
 61    /// Applies the filter to the specified query.
 62    /// </summary>
 63    public IQueryable<StoredTrigger> Apply(IQueryable<StoredTrigger> queryable)
 64    {
 142665        if (Id != null) queryable = queryable.Where(x => x.Id == Id);
 144266        if (Ids != null) queryable = queryable.Where(x => Ids.Contains(x.Id));
 270667        if (WorkflowDefinitionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionId == WorkflowDefinitionI
 142668        if (WorkflowDefinitionIds != null) queryable = queryable.Where(x => WorkflowDefinitionIds.Contains(x.WorkflowDef
 142669        if (WorkflowDefinitionVersionId != null) queryable = queryable.Where(x => x.WorkflowDefinitionVersionId == Workf
 142670        if (WorkflowDefinitionVersionIds != null) queryable = queryable.Where(x => WorkflowDefinitionVersionIds.Contains
 144171        if (Name != null) queryable = queryable.Where(x => x.Name == Name);
 144072        if (Names != null) queryable = queryable.Where(x => Names.Contains(x.Name!));
 152173        if (Hash != null) queryable = queryable.Where(x => x.Hash == Hash);
 142674        return queryable;
 75    }
 76
 777    public static TriggerFilter ByNames(IEnumerable<string> names) => new()
 778    {
 779        Names = names.ToList()
 780    };
 81}