< Summary

Information
Class: Elsa.Workflows.Trigger
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Abstractions/Trigger.cs
Line coverage
22%
Covered lines: 2
Uncovered lines: 7
Coverable lines: 9
Total lines: 70
Line coverage: 22.2%
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%
.ctor(...)100%210%
Elsa.Workflows.ITrigger.GetTriggerPayloadsAsync(...)100%210%
GetTriggerPayloadsAsync(...)100%210%
GetTriggerPayloads(...)100%210%
GetTriggerPayload(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Abstractions/Trigger.cs

#LineLine coverage
 1namespace Elsa.Workflows;
 2
 3/// <summary>
 4/// Represents an activity that acts as a workflow trigger.
 5/// </summary>
 6public abstract class Trigger : Activity, ITrigger
 7{
 8    /// <inheritdoc />
 899    protected Trigger(string? source = null, int? line = null) : base(source, line)
 10    {
 8911    }
 12
 13    /// <inheritdoc />
 014    protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType
 15    {
 016    }
 17
 018    ValueTask<IEnumerable<object>> ITrigger.GetTriggerPayloadsAsync(TriggerIndexingContext context) => GetTriggerPayload
 19
 20    /// <summary>
 21    /// Override this method to return trigger data.
 22    /// </summary>
 23    protected virtual ValueTask<IEnumerable<object>> GetTriggerPayloadsAsync(TriggerIndexingContext context)
 24    {
 025        var hashes = GetTriggerPayloads(context);
 026        return ValueTask.FromResult(hashes);
 27    }
 28
 29    /// <summary>
 30    /// Override this method to return trigger data.
 31    /// </summary>
 032    protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte
 33
 34    /// <summary>
 35    /// Override this method to return a trigger datum.
 36    /// </summary>
 037    protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new();
 38}
 39
 40public abstract class Trigger<TResult> : Activity<TResult>, ITrigger
 41{
 42    protected Trigger(string? source = null, int? line = null) : base(source, line)
 43    {
 44    }
 45
 46    protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType
 47    {
 48    }
 49
 50    ValueTask<IEnumerable<object>> ITrigger.GetTriggerPayloadsAsync(TriggerIndexingContext context) => GetTriggerPayload
 51
 52    /// <summary>
 53    /// Override this method to return trigger data.
 54    /// </summary>
 55    protected virtual ValueTask<IEnumerable<object>> GetTriggerPayloadsAsync(TriggerIndexingContext context)
 56    {
 57        var hashes = GetTriggerPayloads(context);
 58        return ValueTask.FromResult(hashes);
 59    }
 60
 61    /// <summary>
 62    /// Override this method to return a trigger payload.
 63    /// </summary>
 64    protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte
 65
 66    /// <summary>
 67    /// Override this method to return a trigger payload.
 68    /// </summary>
 69    protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new();
 70}