< Summary

Information
Class: Elsa.Extensions.WorkflowExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/WorkflowExtensions.cs
Line coverage
20%
Covered lines: 1
Uncovered lines: 4
Coverable lines: 5
Total lines: 29
Line coverage: 20%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CreatedWithModernTooling(...)100%22100%
WhenCreatedWithModernTooling(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/WorkflowExtensions.cs

#LineLine coverage
 1using Elsa.Workflows.Activities;
 2
 3// ReSharper disable once CheckNamespace
 4namespace Elsa.Extensions;
 5
 6/// <summary>
 7/// Provides extension methods for <see cref="Workflow"/>.
 8/// </summary>
 9public static class WorkflowExtensions
 10{
 11    extension(Workflow workflow)
 12    {
 13        /// <summary>
 14        /// Returns a boolean indicating whether the workflow was created with modern tooling.
 15        /// </summary>
 916        public bool CreatedWithModernTooling() => workflow.WorkflowMetadata.ToolVersion?.Major >= 3;
 17
 18        /// <summary>
 19        /// Executes the specified action depending on whether the workflow was created with modern tooling or not.
 20        /// </summary>
 21        public void WhenCreatedWithModernTooling(Action modernToolingAction, Action legacyToolingAction)
 22        {
 023            if (workflow.CreatedWithModernTooling())
 024                modernToolingAction();
 25            else
 026                legacyToolingAction();
 027        }
 28    }
 29}