< Summary

Information
Class: Elsa.Workflows.Activities.Flowchart.Activities.FlowDecision
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/FlowDecision.cs
Line coverage
76%
Covered lines: 10
Uncovered lines: 3
Coverable lines: 13
Total lines: 50
Line coverage: 76.9%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%
.ctor(...)100%11100%
.ctor(...)100%210%
get_Condition()100%11100%
ExecuteAsync()100%22100%

File(s)

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

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2using Elsa.Expressions.Models;
 3using Elsa.Workflows.Activities.Flowchart.Attributes;
 4using Elsa.Workflows.Attributes;
 5using Elsa.Workflows.Models;
 6using Elsa.Workflows.UIHints;
 7using JetBrains.Annotations;
 8
 9namespace Elsa.Workflows.Activities.Flowchart.Activities;
 10
 11/// <summary>
 12/// Performs a boolean condition and returns an outcome based on the result.
 13/// </summary>
 14[FlowNode("True", "False")]
 15[Activity("Elsa", "Branching", "Evaluate a Boolean condition to determine which path to execute next.", DisplayName = "D
 16[PublicAPI]
 17public class FlowDecision : Activity
 18{
 19    /// <inheritdoc />
 3320    public FlowDecision([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line
 21    {
 3322    }
 23
 24    /// <inheritdoc />
 3225    public FlowDecision(Func<ExpressionExecutionContext, bool> condition, [CallerFilePath] string? source = null, [Calle
 26    {
 3227        Condition = new(condition);
 3228    }
 29
 30    /// <inheritdoc />
 031    public FlowDecision(Func<ExpressionExecutionContext, ValueTask<bool>> condition, [CallerFilePath] string? source = n
 32    {
 033        Condition = new(condition);
 034    }
 35
 36    /// <summary>
 37    /// The condition to evaluate.
 38    /// </summary>
 39    [Input(UIHint = InputUIHints.SingleLine)]
 15640    public Input<bool> Condition { get; set; } = new(new Literal<bool>(false));
 41
 42    /// <inheritdoc />
 43    protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
 44    {
 2945        var result = context.Get(Condition);
 2946        var outcome = result ? "True" : "False";
 47
 2948        await context.CompleteActivityWithOutcomesAsync(outcome);
 2949    }
 50}