< Summary

Information
Class: Elsa.Scheduling.Tasks.RunWorkflowTask
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Tasks/RunWorkflowTask.cs
Line coverage
18%
Covered lines: 3
Uncovered lines: 13
Coverable lines: 16
Total lines: 38
Line coverage: 18.7%
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%
ExecuteAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Tasks/RunWorkflowTask.cs

#LineLine coverage
 1using Elsa.Workflows.Runtime;
 2using Elsa.Workflows.Runtime.Messages;
 3using Microsoft.Extensions.DependencyInjection;
 4
 5namespace Elsa.Scheduling.Tasks;
 6
 7/// <summary>
 8/// A task that runs a workflow.
 9/// </summary>
 10public class RunWorkflowTask : ITask
 11{
 12    private readonly ScheduleNewWorkflowInstanceRequest _request;
 13
 14    /// <summary>
 15    /// Initializes a new instance of the <see cref="RunWorkflowTask"/> class.
 16    /// </summary>
 317    public RunWorkflowTask(ScheduleNewWorkflowInstanceRequest request)
 18    {
 319        _request = request;
 320    }
 21
 22    /// <inheritdoc />
 23    public async ValueTask ExecuteAsync(TaskExecutionContext context)
 24    {
 025        var workflowRuntime = context.ServiceProvider.GetRequiredService<IWorkflowRuntime>();
 026        var workflowClient = await workflowRuntime.CreateClientAsync();
 027        var request = new CreateAndRunWorkflowInstanceRequest
 028        {
 029            WorkflowDefinitionHandle = _request.WorkflowDefinitionHandle,
 030            TriggerActivityId = _request.TriggerActivityId,
 031            Input = _request.Input,
 032            Properties = _request.Properties,
 033            ParentId = _request.ParentId,
 034            CorrelationId = _request.CorrelationId
 035        };
 036        await workflowClient.CreateAndRunInstanceAsync(request);
 037    }
 38}