using Elsa.Workflows; namespace Elsa.Testing.Shared; /// /// Provides extension methods for to enhance its functionality. /// public static class ActivityExecutionContextExtensions { /// The activity execution context instance used for checking the scheduled activity. extension(ActivityExecutionContext activityExecutionContext) { /// /// Determines whether the specified activity is scheduled in the workflow execution context. /// /// The activity to check for scheduling. /// True if the specified activity is scheduled; otherwise, false. public bool HasScheduledActivity(IActivity activity) { return activityExecutionContext.WorkflowExecutionContext.Scheduler.Find(x => x.Activity == activity) != null; } /// /// Retrieves the collection of outcomes recorded in the execution context's journal data. /// /// A collection of outcome strings, or an empty collection if no outcomes are present. public IEnumerable GetOutcomes() { return activityExecutionContext.JournalData.TryGetValue("Outcomes", out var outcomes) && outcomes is string[] arr ? arr : []; } /// /// Determines whether the specified outcome exists in the current activity execution context. /// /// The outcome to verify within the execution context. /// True if the specified outcome exists; otherwise, false. public bool HasOutcome(string outcome) { return activityExecutionContext.GetOutcomes().Contains(outcome); } } }