< Summary

Information
Class: Elsa.Extensions.DelayActivityExecutionContextExtensions
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Extensions/DelayActivityExecutionContextExtensions.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 45
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
DelayFor(...)100%11100%
DelayUntil(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Extensions/DelayActivityExecutionContextExtensions.cs

#LineLine coverage
 1using Elsa.Common;
 2using Elsa.Scheduling;
 3using Elsa.Scheduling.Bookmarks;
 4using Elsa.Workflows;
 5using Elsa.Workflows.Models;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Extensions;
 9
 10public static class DelayActivityExecutionContextExtensions
 11{
 12    /// <summary>
 13    /// Resumes the activity after a specified delay.
 14    /// </summary>
 15    /// <param name="context">The activity execution context in which the workflow is running.</param>
 16    /// <param name="delay">The delay before the workflow resumes.</param>
 17    /// <param name="callback">The delegate to execute when the activity resumes.</param>
 18    public static void DelayFor(this ActivityExecutionContext context, TimeSpan delay, ExecuteActivityDelegate? callback
 19    {
 2720        var clock = context.ExpressionExecutionContext.GetRequiredService<ISystemClock>();
 2721        var resumeAt = clock.UtcNow.Add(delay);
 22
 2723        DelayUntil(context, resumeAt, callback);
 2724    }
 25
 26    /// <summary>
 27    /// Resumes the activity at a specified point in time.
 28    /// </summary>
 29    /// <param name="context">The activity execution context in which the workflow is running.</param>
 30    /// <param name="resumeAt">The point in time at which the workflow should resume execution.</param>
 31    /// <param name="callback">The delegate to execute when the activity resumes.</param>
 32    public static void DelayUntil(this ActivityExecutionContext context, DateTimeOffset resumeAt, ExecuteActivityDelegat
 33    {
 3034        var payload = new DelayPayload(resumeAt);
 35
 3036        var bookmarkOptions = new CreateBookmarkArgs
 3037        {
 3038            BookmarkName = SchedulingStimulusNames.Delay,
 3039            Stimulus = payload,
 3040            Callback = callback
 3041        };
 42
 3043        context.CreateBookmark(bookmarkOptions);
 3044    }
 45}