< Summary

Information
Class: Elsa.Workflows.PortResolvers.SwitchActivityResolver
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/PortResolvers/SwitchActivityPortResolver.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 35
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
get_Priority()100%11100%
GetSupportsActivity(...)100%11100%
GetActivityPortsAsync(...)100%11100%
GetPortsInternal()100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/PortResolvers/SwitchActivityPortResolver.cs

#LineLine coverage
 1using Elsa.Workflows.Activities;
 2using Elsa.Workflows.Models;
 3
 4namespace Elsa.Workflows.PortResolvers;
 5
 6/// <summary>
 7/// Returns a list of outbound activities for a given <see cref="Switch"/> activity's branches.
 8/// </summary>
 9public class SwitchActivityResolver : IActivityResolver
 10{
 11    /// <inheritdoc />
 85112    public int Priority => 0;
 13
 14    /// <inheritdoc />
 1744315    public bool GetSupportsActivity(IActivity activity) => activity is Switch;
 16
 17    /// <inheritdoc />
 18    public ValueTask<IEnumerable<ActivityPort>> GetActivityPortsAsync(IActivity activity, CancellationToken cancellation
 19    {
 1320        var ports = GetPortsInternal(activity).ToList();
 1321        return new(ports);
 22    }
 23
 24    private static IEnumerable<ActivityPort> GetPortsInternal(IActivity activity)
 25    {
 1326        var @switch = (Switch)activity;
 2727        var cases = @switch.Cases.Where(x => x.Activity != null);
 28
 5429        foreach (var @case in cases)
 1430            yield return ActivityPort.FromActivity(@case.Activity!, @case.Label);
 31
 1332        if (@switch.Default != null)
 633            yield return ActivityPort.FromActivity(@switch.Default, nameof(Switch.Default));
 1334    }
 35}