< Summary

Information
Class: Elsa.Scheduling.Activities.TimerBase
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Activities/TimerBase.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 43
Line coverage: 100%
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%
OnTimerElapsedAsync(...)100%11100%
OnTimerElapsed(...)100%11100%
Execute(...)100%11100%
GetTriggerPayload(...)100%11100%
TimerElapsedAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Activities/TimerBase.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2using Elsa.Expressions.Models;
 3using Elsa.Extensions;
 4using Elsa.Workflows;
 5
 6namespace Elsa.Scheduling.Activities;
 7
 8/// <summary>
 9/// </summary>
 3110public abstract class TimerBase([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : EventGene
 11{
 12    protected abstract TimeSpan GetInterval(ExpressionExecutionContext context);
 13
 14    protected virtual ValueTask OnTimerElapsedAsync(ActivityExecutionContext context)
 15    {
 216        OnTimerElapsed(context);
 217        return default;
 18    }
 19
 20    protected virtual void OnTimerElapsed(ActivityExecutionContext context)
 21    {
 222    }
 23
 24    /// <inheritdoc />
 25    protected override void Execute(ActivityExecutionContext context)
 26    {
 727        var interval = GetInterval(context.ExpressionExecutionContext);
 728        context.RepeatWithInterval(interval, TimerElapsedAsync);
 729    }
 30
 31    /// <inheritdoc />
 32    protected override object GetTriggerPayload(TriggerIndexingContext context)
 33    {
 434        var interval = GetInterval(context.ExpressionExecutionContext);
 435        return context.GetTimerTriggerStimulus(interval);
 36    }
 37
 38    private async ValueTask TimerElapsedAsync(ActivityExecutionContext context)
 39    {
 240        await OnTimerElapsedAsync(context);
 241        await context.CompleteActivityAsync();
 242    }
 43}