< Summary

Information
Class: Elsa.Workflows.Trigger<T>
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Abstractions/Trigger.cs
Line coverage
66%
Covered lines: 6
Uncovered lines: 3
Coverable lines: 9
Total lines: 70
Line coverage: 66.6%
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%11100%
GetTriggerPayloadsAsync(...)100%11100%
GetTriggerPayloads(...)100%11100%
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 />
 9    protected Trigger(string? source = null, int? line = null) : base(source, line)
 10    {
 11    }
 12
 13    /// <inheritdoc />
 14    protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType
 15    {
 16    }
 17
 18    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    {
 25        var hashes = GetTriggerPayloads(context);
 26        return ValueTask.FromResult(hashes);
 27    }
 28
 29    /// <summary>
 30    /// Override this method to return trigger data.
 31    /// </summary>
 32    protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte
 33
 34    /// <summary>
 35    /// Override this method to return a trigger datum.
 36    /// </summary>
 37    protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new();
 38}
 39
 40public abstract class Trigger<TResult> : Activity<TResult>, ITrigger
 41{
 41142    protected Trigger(string? source = null, int? line = null) : base(source, line)
 43    {
 41144    }
 45
 046    protected Trigger(string activityType, int version = 1, string? source = null, int? line = null) : base(activityType
 47    {
 048    }
 49
 6150    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    {
 6157        var hashes = GetTriggerPayloads(context);
 6158        return ValueTask.FromResult(hashes);
 59    }
 60
 61    /// <summary>
 62    /// Override this method to return a trigger payload.
 63    /// </summary>
 1464    protected virtual IEnumerable<object> GetTriggerPayloads(TriggerIndexingContext context) => [GetTriggerPayload(conte
 65
 66    /// <summary>
 67    /// Override this method to return a trigger payload.
 68    /// </summary>
 069    protected virtual object GetTriggerPayload(TriggerIndexingContext context) => new();
 70}