< 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
50%
Covered lines: 5
Uncovered lines: 5
Coverable lines: 10
Total lines: 36
Line coverage: 50%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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()50%3244.44%

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,
 52213    IOptions<WorkflowDispatcherOptions> options) : WorkflowExecutionMiddleware(next)
 14{
 15    /// <inheritdoc />
 16    public override async ValueTask InvokeAsync(WorkflowExecutionContext context)
 17    {
 54818        if (!options.Value.UseTransactionalOutbox)
 19        {
 54820            await Next(context);
 54821            return;
 22        }
 23
 024        var previousContext = accessor.WorkflowExecutionContext;
 025        accessor.WorkflowExecutionContext = context;
 26
 27        try
 28        {
 029            await Next(context);
 030        }
 31        finally
 32        {
 033            accessor.WorkflowExecutionContext = previousContext;
 34        }
 54835    }
 36}