< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.CancelBackgroundActivities
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/CancelBackgroundActivities.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 28
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
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%44100%

File(s)

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

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Mediator.Contracts;
 3using Elsa.Workflows.Runtime.Middleware.Activities;
 4using Elsa.Workflows.Runtime.Notifications;
 5using Elsa.Workflows.Runtime.Stimuli;
 6using JetBrains.Annotations;
 7
 8namespace Elsa.Workflows.Runtime.Handlers;
 9
 10/// <summary>
 11/// A handler that cancels background activities based on removed bookmarks.
 12/// </summary>
 13[UsedImplicitly]
 46714public class CancelBackgroundActivities(IBackgroundActivityScheduler backgroundActivityScheduler) : INotificationHandler
 15{
 16    /// <inheritdoc />
 17    public async Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken)
 18    {
 51219        var removedBookmarks = notification.IndexedWorkflowBookmarks.RemovedBookmarks.Where(x => x.Name == BackgroundAct
 20
 93821        foreach (var removedBookmark in removedBookmarks)
 22        {
 323            var payload = removedBookmark.GetPayload<BackgroundActivityStimulus>();
 324            if (payload.JobId != null)
 325                await backgroundActivityScheduler.UnscheduledAsync(payload.JobId, cancellationToken);
 26        }
 46627    }
 28}