< Summary

Information
Class: Elsa.Workflows.Runtime.Activities.EventBase<T>
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Activities/EventBase.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 42
Line coverage: 0%
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
OnEventReceivedAsync(...)100%210%
OnEventReceived(...)100%210%
GetTriggerPayload(...)100%210%
ExecuteAsync(...)100%210%
EventReceivedAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Activities/EventBase.cs

#LineLine coverage
 1using Elsa.Expressions.Models;
 2using Elsa.Extensions;
 3
 4namespace Elsa.Workflows.Runtime.Activities;
 5
 6public abstract class EventBase : Trigger<object>;
 7
 8public abstract class EventBase<TResult> : Trigger<TResult>
 9{
 10    protected abstract string GetEventName(ExpressionExecutionContext context);
 11
 12    protected virtual ValueTask OnEventReceivedAsync(ActivityExecutionContext context, TResult? input)
 13    {
 014        OnEventReceived(context, input);
 015        return default;
 16    }
 17
 18    protected virtual void OnEventReceived(ActivityExecutionContext context, TResult? input)
 19    {
 020    }
 21
 22    protected override object GetTriggerPayload(TriggerIndexingContext context)
 23    {
 024        var eventName = GetEventName(context.ExpressionExecutionContext);
 025        return context.GetEventStimulus(eventName);
 26    }
 27
 28    protected override ValueTask ExecuteAsync(ActivityExecutionContext context)
 29    {
 030        var eventName = GetEventName(context.ExpressionExecutionContext);
 031        context.WaitForEvent(eventName, EventReceivedAsync);
 032        return default;
 33    }
 34
 35    protected async ValueTask EventReceivedAsync(ActivityExecutionContext context)
 36    {
 037        var input = (TResult?)context.GetEventInput();
 038        Result.Set(context, input);
 039        await OnEventReceivedAsync(context, input);
 040        await context.CompleteActivityAsync();
 041    }
 42}