< Summary

Information
Class: Elsa.Workflows.Activities.Flowchart.Extensions.ActivityExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/ActivityExtensions.cs
Line coverage
91%
Covered lines: 21
Uncovered lines: 2
Coverable lines: 23
Total lines: 55
Line coverage: 91.3%
Branch coverage
77%
Covered branches: 14
Total branches: 18
Branch coverage: 77.7%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetMergeMode(...)60%111077.77%
SetMergeMode(...)100%44100%
GetMergeModeAsync()100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/ActivityExtensions.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Workflows.Activities.Flowchart.Activities;
 3using Elsa.Workflows.Activities.Flowchart.Models;
 4
 5namespace Elsa.Workflows.Activities.Flowchart.Extensions;
 6
 7public static class ActivityExtensions
 8{
 9    extension(IActivity activity)
 10    {
 11        public MergeMode? GetMergeMode()
 12        {
 32913            if (!activity.CustomProperties.TryGetValue("mergeMode", out var value))
 31014                return null;
 15
 16            // Handle both string and enum values for backwards compatibility
 1917            var result = value switch
 1918            {
 019                MergeMode mode => mode,
 3820                string str when Enum.TryParse<MergeMode>(str, true, out var mode) => mode,
 021                _ => (MergeMode?)null
 1922            };
 23
 24            // Treat MergeMode.None as equivalent to null (no merge mode set)
 1925            return result == MergeMode.None ? null : result;
 26        }
 27
 28        public void SetMergeMode(MergeMode? value)
 29        {
 30            // Treat MergeMode.None as equivalent to null (no merge mode set)
 1131            if (value == null || value == MergeMode.None)
 132                activity.CustomProperties.Remove("mergeMode");
 33            else
 1034                activity.CustomProperties["mergeMode"] = value.ToString()!;
 1035        }
 36
 37        public async Task<MergeMode?> GetMergeModeAsync(ActivityExecutionContext context)
 38        {
 34339            if (activity.Type != "Elsa.FlowJoin")
 40            {
 32941                return activity.GetMergeMode();
 42            }
 43
 44            // Handle deprecated FlowJoin activity by evaluating its JoinMode property and mapping it to the appropriate
 1445            var joinActivityExecutionContext = await context.WorkflowExecutionContext.CreateActivityExecutionContextAsyn
 1446            var joinMode = await joinActivityExecutionContext.EvaluateInputPropertyAsync<FlowJoin, FlowJoinMode>(x => x.
 47
 1448            return joinMode switch
 1449            {
 750                FlowJoinMode.WaitAny => MergeMode.Race,
 751                _ => MergeMode.Merge // WaitAll maps to Merge (wait for all activated branches)
 1452            };
 34353        }
 54    }
 55}