< Summary

Information
Class: Elsa.Extensions.ActivityExecutionContextEventExtensions
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/ActivityExecutionContextEventExtensions.cs
Line coverage
100%
Covered lines: 15
Uncovered lines: 0
Coverable lines: 15
Total lines: 46
Line coverage: 100%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
WaitForEvent(...)100%44100%
GetEventStimulus(...)100%11100%
GetEventInput(...)50%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/ActivityExecutionContextEventExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Models;
 3using Elsa.Workflows.Runtime;
 4using Elsa.Workflows.Runtime.Activities;
 5using Elsa.Workflows.Runtime.Stimuli;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Extensions;
 9
 10public static class ActivityExecutionContextEventExtensions
 11{
 12    /// <summary>
 13    /// Suspends the current activity's execution and waits for a specified event to occur before continuing.
 14    /// </summary>
 15    /// <param name="context">The activity execution context associated with the current activity execution.</param>
 16    /// <param name="eventName">The name of the event to wait for.</param>
 17    /// <param name="callback">An optional delegate to execute when the event occurs.</param>
 18    public static void WaitForEvent(this ActivityExecutionContext context, string eventName, ExecuteActivityDelegate? ca
 19    {
 2220        if (context.IsTriggerOfWorkflow())
 21        {
 522            callback?.Invoke(context);
 523            return;
 24        }
 25
 1726        var options = new CreateBookmarkArgs
 1727        {
 1728            Stimulus = new EventStimulus(eventName),
 1729            IncludeActivityInstanceId = false,
 1730            BookmarkName = RuntimeStimulusNames.Event,
 1731            Callback = callback
 1732        };
 1733        context.CreateBookmark(options);
 1734    }
 35
 36    public static EventStimulus GetEventStimulus(this TriggerIndexingContext context, string eventName)
 37    {
 1638        context.TriggerName = RuntimeStimulusNames.Event;
 1639        return new(eventName);
 40    }
 41
 42    public static object? GetEventInput(this ActivityExecutionContext context)
 43    {
 1544        return context.TryGetWorkflowInput<object?>(Event.EventInputWorkflowInputKey, out var input) ? input : null;
 45    }
 46}