< Summary

Information
Class: Elsa.Workflows.ActivityInvoker
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/ActivityInvoker.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 50
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
.ctor(...)100%11100%
InvokeAsync()83.33%66100%
InvokeAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/ActivityInvoker.cs

#LineLine coverage
 1using Elsa.Workflows.Options;
 2using Microsoft.Extensions.Logging;
 3
 4namespace Elsa.Workflows;
 5
 6/// <inheritdoc />
 4217public class ActivityInvoker(
 4218    IActivityExecutionPipeline pipeline,
 4219    ILoggerStateGenerator<ActivityExecutionContext> loggerStateGenerator,
 42110    ILogger<ActivityInvoker> logger)
 11    : IActivityInvoker
 12{
 13
 14    /// <inheritdoc />
 15    public async Task<ActivityExecutionContext> InvokeAsync(WorkflowExecutionContext workflowExecutionContext, IActivity
 16    {
 17        // Setup an activity execution context, potentially reusing an existing one if requested.
 301918        var existingActivityExecutionContext = options?.ExistingActivityExecutionContext;
 19
 20        // Perform a lookup to make sure the activity execution context is part of the workflow execution context.
 301921        var activityExecutionContext = existingActivityExecutionContext != null
 4222            ? workflowExecutionContext.ActivityExecutionContexts.FirstOrDefault(x => x.Id == existingActivityExecutionCo
 301923            : null;
 24
 301925        if (activityExecutionContext == null)
 26        {
 27            // Create a new activity execution context.
 298328            activityExecutionContext = await workflowExecutionContext.CreateActivityExecutionContextAsync(activity, opti
 298329            activityExecutionContext.Taint();
 30
 31            // Add the activity context to the workflow context.
 298332            workflowExecutionContext.AddActivityExecutionContext(activityExecutionContext);
 33        }
 34
 35        // Execute the activity execution pipeline.
 301936        await InvokeAsync(activityExecutionContext);
 37
 301938        return activityExecutionContext;
 301939    }
 40
 41    /// <inheritdoc />
 42    public async Task InvokeAsync(ActivityExecutionContext activityExecutionContext)
 43    {
 301944        var loggerState = loggerStateGenerator.GenerateLoggerState(activityExecutionContext);
 301945        using var loggingScope = logger.BeginScope(loggerState);
 46
 47        // Execute the activity execution pipeline.
 301948        await pipeline.ExecuteAsync(activityExecutionContext);
 301949    }
 50}