< Summary

Information
Class: Elsa.Testing.Shared.ActivityExecutionContextExtensions
Assembly: Elsa.Testing.Shared
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/ActivityExecutionContextExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 42
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HasScheduledActivity(...)100%210%
GetOutcomes(...)0%2040%
HasOutcome(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/ActivityExecutionContextExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2
 3namespace Elsa.Testing.Shared;
 4
 5/// <summary>
 6/// Provides extension methods for <see cref="ActivityExecutionContext"/> to enhance its functionality.
 7/// </summary>
 8public static class ActivityExecutionContextExtensions
 9{
 10    /// <param name="activityExecutionContext">The activity execution context instance used for checking the scheduled a
 11    extension(ActivityExecutionContext activityExecutionContext)
 12    {
 13        /// <summary>
 14        /// Determines whether the specified activity is scheduled in the workflow execution context.
 15        /// </summary>
 16        /// <param name="activity">The activity to check for scheduling.</param>
 17        /// <returns>True if the specified activity is scheduled; otherwise, false.</returns>
 18        public bool HasScheduledActivity(IActivity activity)
 19        {
 020            return activityExecutionContext.WorkflowExecutionContext.Scheduler.Find(x => x.Activity == activity) != null
 21        }
 22
 23        /// <summary>
 24        /// Retrieves the collection of outcomes recorded in the execution context's journal data.
 25        /// </summary>
 26        /// <returns>A collection of outcome strings, or an empty collection if no outcomes are present.</returns>
 27        public IEnumerable<string> GetOutcomes()
 28        {
 029            return activityExecutionContext.JournalData.TryGetValue("Outcomes", out var outcomes) && outcomes is string[
 30        }
 31
 32        /// <summary>
 33        /// Determines whether the specified outcome exists in the current activity execution context.
 34        /// </summary>
 35        /// <param name="outcome">The outcome to verify within the execution context.</param>
 36        /// <returns>True if the specified outcome exists; otherwise, false.</returns>
 37        public bool HasOutcome(string outcome)
 38        {
 039            return activityExecutionContext.GetOutcomes().Contains(outcome);
 40        }
 41    }
 42}