< Summary

Information
Class: Elsa.Workflows.Runtime.ActivationValidators.CorrelationStrategy
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/ActivationValidators/CorrelationStrategy.cs
Line coverage
11%
Covered lines: 1
Uncovered lines: 8
Coverable lines: 9
Total lines: 27
Line coverage: 11.1%
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%
GetAllowActivationAsync()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/ActivationValidators/CorrelationStrategy.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using Elsa.Workflows.Management;
 3using Elsa.Workflows.Management.Filters;
 4
 5namespace Elsa.Workflows.Runtime.ActivationValidators;
 6
 7/// <summary>
 8/// Only allow new workflow instances if a running one with the same correlation ID doesn't already exist.
 9/// </summary>
 10[Display(Name = "Correlation", Description = "Only allow new workflow instances of any workflow definition if a running 
 6811public class CorrelationStrategy(IWorkflowInstanceStore workflowInstanceStore) : IWorkflowActivationStrategy
 12{
 13    /// <summary>
 14    /// Only allow a new instance if no running ones exist already.
 15    /// </summary>
 16    public async ValueTask<bool> GetAllowActivationAsync(WorkflowInstantiationStrategyContext context)
 17    {
 018        var filter = new WorkflowInstanceFilter
 019        {
 020            CorrelationId = context.CorrelationId,
 021            WorkflowStatus = WorkflowStatus.Running
 022        };
 23
 024        var count = await workflowInstanceStore.CountAsync(filter);
 025        return count == 0;
 026    }
 27}