< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.CancelWorkflowsCommandHandler
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandHandler.cs
Line coverage
16%
Covered lines: 1
Uncovered lines: 5
Coverable lines: 6
Total lines: 23
Line coverage: 16.6%
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%
HandleAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/CancelWorkflowsCommandHandler.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Mediator.Models;
 3using Elsa.Workflows.Runtime.Commands;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Workflows.Runtime.Handlers;
 7
 8/// <summary>
 9/// Handles the <see cref="CancelWorkflowsCommand"/>.
 10/// </summary>
 11[UsedImplicitly]
 5312public class CancelWorkflowsCommandHandler(IWorkflowRuntime workflowRuntime) : ICommandHandler<CancelWorkflowsCommand>
 13{
 14    /// <inheritdoc />
 15    public async Task<Unit> HandleAsync(CancelWorkflowsCommand command, CancellationToken cancellationToken)
 16    {
 017        var workflowInstanceId = command.Request.WorkflowInstanceId;
 018        var workflowClient = await workflowRuntime.CreateClientAsync(workflowInstanceId, cancellationToken);
 019        await workflowClient.CancelAsync(cancellationToken);
 20
 021        return Unit.Instance;
 022    }
 23}