< Summary

Information
Class: Elsa.Workflows.Runtime.WorkflowCanceler
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCanceler.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 36
Line coverage: 100%
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
.ctor(...)100%11100%
CancelWorkflowAsync()100%11100%
CancelWorkflowAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCanceler.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Workflows.Models;
 3using Elsa.Workflows.Pipelines.WorkflowExecution;
 4using Elsa.Workflows.Runtime.Middleware.Workflows;
 5using Elsa.Workflows.Runtime.Notifications;
 6using Elsa.Workflows.State;
 7
 8namespace Elsa.Workflows.Runtime;
 9
 10/// <inheritdoc />
 14111public class WorkflowCanceler(
 14112    IWorkflowExecutionPipeline workflowExecutionPipeline,
 14113    IWorkflowStateExtractor workflowStateExtractor,
 14114    IMediator mediator,
 14115    IServiceProvider serviceProvider) : IWorkflowCanceler
 16{
 17    /// <inheritdoc />
 18    public async Task<WorkflowState> CancelWorkflowAsync(WorkflowGraph workflowGraph, WorkflowState workflowState, Cance
 19    {
 520        var workflowExecutionContext = await WorkflowExecutionContext.CreateAsync(serviceProvider, workflowGraph, workfl
 521        await CancelWorkflowAsync(workflowExecutionContext, cancellationToken);
 522        return workflowStateExtractor.Extract(workflowExecutionContext);
 523    }
 24
 25    /// <inheritdoc />
 26    public async Task CancelWorkflowAsync(WorkflowExecutionContext workflowExecutionContext, CancellationToken cancellat
 27    {
 528        await mediator.SendAsync(new WorkflowCancelling(workflowExecutionContext.Id), cancellationToken);
 529        var pipelineBuilder = new WorkflowExecutionPipelineBuilder(serviceProvider);
 530        workflowExecutionPipeline.ConfigurePipelineBuilder(pipelineBuilder);
 531        pipelineBuilder.ReplaceTerminal<CancelWorkflowMiddleware>();
 532        var pipeline = pipelineBuilder.Build();
 533        await pipeline(workflowExecutionContext);
 534        await mediator.SendAsync(new WorkflowCancelled(workflowExecutionContext.Id), cancellationToken);
 535    }
 36}