< Summary

Information
Class: Elsa.Alterations.Handlers.ResumeWorkflowInstance
Assembly: Elsa.Alterations
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Handlers/ResumeWorkflowInstance.cs
Line coverage
30%
Covered lines: 3
Uncovered lines: 7
Coverable lines: 10
Total lines: 43
Line coverage: 30%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
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()0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations/Handlers/ResumeWorkflowInstance.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Enums;
 2using Elsa.Alterations.Core.Notifications;
 3using Elsa.Mediator.Contracts;
 4using Elsa.Workflows.Runtime;
 5using Elsa.Workflows.Runtime.Contracts;
 6using Elsa.Workflows.Runtime.Requests;
 7using JetBrains.Annotations;
 8
 9namespace Elsa.Alterations.Handlers;
 10
 11/// <summary>
 12/// Resumes a workflow instance when an alteration job has been completed and the workflow contains scheduled work.
 13/// </summary>
 14[UsedImplicitly]
 15public class ResumeWorkflowInstance : INotificationHandler<AlterationJobCompleted>
 16{
 17    private readonly IWorkflowDispatcher _workflowDispatcher;
 18
 19    /// <summary>
 20    /// Initializes a new instance of the <see cref="ResumeWorkflowInstance"/> class.
 21    /// </summary>
 32022    public ResumeWorkflowInstance(IWorkflowDispatcher workflowDispatcher)
 23    {
 32024        _workflowDispatcher = workflowDispatcher;
 32025    }
 26
 27    /// <inheritdoc />
 28    public async Task HandleAsync(AlterationJobCompleted notification, CancellationToken cancellationToken)
 29    {
 030        var job = notification.Job;
 31
 32        // Check if job is completed.
 033        if(job.Status != AlterationJobStatus.Completed)
 034            return;
 35
 36        // Check if the workflow contains scheduled work.
 037        if(!notification.WorkflowContainsScheduledWork)
 038            return;
 39
 40        // Resume workflow instance.
 041        await _workflowDispatcher.DispatchAsync(new DispatchWorkflowInstanceRequest(job.WorkflowInstanceId), cancellatio
 042    }
 43}