| | | 1 | | using Elsa.Extensions; |
| | | 2 | | using Elsa.Workflows; |
| | | 3 | | using Elsa.Workflows.Models; |
| | | 4 | | using Elsa.Workflows.Options; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Testing.Shared; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Provides a fake implementation of the <see cref="IActivityExecutionContextSchedulerStrategy"/> interface, |
| | | 10 | | /// designed for testing purposes. This class allows scheduling of activities within an activity execution context |
| | | 11 | | /// and enables control over workflows in a simulated environment. |
| | | 12 | | /// </summary> |
| | | 13 | | public class FakeActivityExecutionContextSchedulerStrategy : IActivityExecutionContextSchedulerStrategy |
| | | 14 | | { |
| | | 15 | | /// <summary> |
| | | 16 | | /// Schedules the provided activity for execution within the given activity execution context. |
| | | 17 | | /// </summary> |
| | | 18 | | /// <param name="context">The current activity execution context in which to schedule the activity.</param> |
| | | 19 | | /// <param name="activity">The activity to be scheduled. Can be null, in which case no operation is performed.</para |
| | | 20 | | /// <param name="owner">The owner activity execution context, if any.</param> |
| | | 21 | | /// <param name="options">Optional scheduling options to influence how the activity is scheduled.</param> |
| | | 22 | | public Task ScheduleActivityAsync(ActivityExecutionContext context, IActivity? activity, ActivityExecutionContext? o |
| | | 23 | | { |
| | 0 | 24 | | if (activity == null) |
| | 0 | 25 | | return Task.CompletedTask; |
| | | 26 | | |
| | 0 | 27 | | var activityNode = new ActivityNode(activity!, ""); |
| | 0 | 28 | | return ScheduleActivityAsync(context, activityNode, owner, options); |
| | | 29 | | } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Schedules the provided activity for execution within the specified activity execution context using the given sc |
| | | 33 | | /// </summary> |
| | | 34 | | /// <param name="context">The activity execution context in which the activity will be scheduled.</param> |
| | | 35 | | /// <param name="activityNode">The activity node to be scheduled. If null, no operation is performed.</param> |
| | | 36 | | /// <param name="owner">The owner activity execution context, if any, that triggered the scheduling request.</param> |
| | | 37 | | /// <param name="options">Optional scheduling parameters to customize the scheduling behavior.</param> |
| | | 38 | | public Task ScheduleActivityAsync(ActivityExecutionContext context, ActivityNode? activityNode, ActivityExecutionCon |
| | | 39 | | { |
| | 0 | 40 | | if (activityNode == null) |
| | 0 | 41 | | return Task.CompletedTask; |
| | | 42 | | |
| | 0 | 43 | | context.WorkflowExecutionContext.Schedule(activityNode!, owner ?? context, options); |
| | 0 | 44 | | return Task.CompletedTask; |
| | | 45 | | } |
| | | 46 | | } |