< Summary

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

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ScheduleActivityAsync(...)0%620%
ScheduleActivityAsync(...)0%2040%

File(s)

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

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Workflows;
 3using Elsa.Workflows.Models;
 4using Elsa.Workflows.Options;
 5
 6namespace 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>
 13public 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    {
 024        if (activity == null)
 025            return Task.CompletedTask;
 26
 027        var activityNode = new ActivityNode(activity!, "");
 028        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    {
 040        if (activityNode == null)
 041            return Task.CompletedTask;
 42
 043        context.WorkflowExecutionContext.Schedule(activityNode!, owner ?? context, options);
 044        return Task.CompletedTask;
 45    }
 46}