< Summary

Information
Class: Elsa.Workflows.Runtime.Middleware.Workflows.WorkflowDispatchOutboxMiddleware
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Middleware/Workflows/WorkflowDispatchOutboxMiddleware.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 36
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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()100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Middleware/Workflows/WorkflowDispatchOutboxMiddleware.cs

#LineLine coverage
 1using Elsa.Workflows.Pipelines.WorkflowExecution;
 2using Elsa.Workflows.Runtime.Options;
 3using Microsoft.Extensions.Options;
 4
 5namespace Elsa.Workflows.Runtime.Middleware.Workflows;
 6
 7/// <summary>
 8/// Makes the current workflow execution context available to the workflow dispatch outbox.
 9/// </summary>
 10public class WorkflowDispatchOutboxMiddleware(
 11    WorkflowMiddlewareDelegate next,
 12    IWorkflowDispatchOutboxAccessor accessor,
 57913    IOptions<WorkflowDispatcherOptions> options) : WorkflowExecutionMiddleware(next)
 14{
 15    /// <inheritdoc />
 16    public override async ValueTask InvokeAsync(WorkflowExecutionContext context)
 17    {
 61418        if (!options.Value.UseTransactionalOutbox)
 19        {
 61220            await Next(context);
 61221            return;
 22        }
 23
 224        var previousContext = accessor.WorkflowExecutionContext;
 225        accessor.WorkflowExecutionContext = context;
 26
 27        try
 28        {
 229            await Next(context);
 230        }
 31        finally
 32        {
 233            accessor.WorkflowExecutionContext = previousContext;
 34        }
 61435    }
 36}