* Introduce `FlowchartExecutionMode` to streamline flowchart execution logic. - Added `FlowchartExecutionMode` enum to represent execution modes (Default, TokenBased, CounterBased). - Updated flowchart-related integration and unit tests to use the new execution mode. - Removed the global `UseTokenFlow` flag in favor of execution-specific configuration via `RunWorkflowOptions`. - Refactored flowchart-related APIs and test helpers for improved flexibility and modularity. * Add support for configuring flowchart execution behavior via `FlowchartOptions` and DI. - Introduced extensions for `FlowchartFeature` to simplify configuration. - Added DI support for setting default execution modes. - Refactored flowchart execution logic to prioritize configuration. * Update default Flowchart execution settings to align with version 3.5.2 behavior - Changed `DefaultExecutionMode` to `CounterBased`. - Updated `UseTokenFlow` default to `false`. * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Models/FlowchartExecutionMode.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/FlowchartFeatureExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Scenarios/FlowchartNextActivity/Tests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Extensions/RunWorkflowOptionsExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart integration tests for improved formatting and consistency * Refactor workflow tests and related services to improve reusability and align with updated Flowchart execution behavior * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Options/FlowchartOptions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Refactor flowchart execution logic to use `FlowchartExecutionMode` enum, replacing boolean checks for improved clarity and extensibility. * Refactor tests and workflow logic to replace boolean `useTokenFlow` with `FlowchartExecutionMode` enum for clarity and consistency. * Refactor flowchart execution logic to centralize mode-based behavior handling and simplify implementation. * Remove unnecessary whitespace in Flowchart.cs to improve code formatting * Remove unnecessary whitespace in FlowJoinTests.cs to improve code formatting * Update src/common/Elsa.Testing.Shared.Integration/WorkflowTestFixture.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using Elsa.Testing.Shared;
|
|
using Elsa.Workflows;
|
|
using Elsa.Workflows.Activities.Flowchart.Activities;
|
|
using Elsa.Workflows.Activities.Flowchart.Extensions;
|
|
using Elsa.Workflows.Activities.Flowchart.Models;
|
|
using Elsa.Workflows.Models;
|
|
using Elsa.Workflows.Options;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Elsa.Activities.IntegrationTests.Flow;
|
|
|
|
/// <summary>
|
|
/// Shared helper methods for Flowchart integration tests.
|
|
/// </summary>
|
|
public static class FlowchartTestHelpers
|
|
{
|
|
public static IServiceProvider CreateServiceProvider(ITestOutputHelper testOutputHelper, CapturingTextWriter? capturingTextWriter = null)
|
|
{
|
|
var builder = new TestApplicationBuilder(testOutputHelper);
|
|
if (capturingTextWriter != null)
|
|
builder.WithCapturingTextWriter(capturingTextWriter);
|
|
return builder.Build();
|
|
}
|
|
|
|
public static async Task<RunWorkflowResult> RunFlowchartAsync(IServiceProvider services, Flowchart flowchart, FlowchartExecutionMode? executionMode = null)
|
|
{
|
|
var options = executionMode.HasValue
|
|
? new RunWorkflowOptions().WithFlowchartExecutionMode(executionMode.Value)
|
|
: null;
|
|
|
|
return await services.RunActivityAsync(flowchart, options);
|
|
}
|
|
|
|
public static Connection CreateConnection(IActivity source, IActivity target, string? outcome = "Done")
|
|
{
|
|
return new(new(source, outcome), new Endpoint(target));
|
|
}
|
|
|
|
public static Flowchart CreateSimpleLinearFlowchart(params IActivity[] activities)
|
|
{
|
|
var flowchart = new Flowchart
|
|
{
|
|
Start = activities.FirstOrDefault(),
|
|
Activities = new List<IActivity>(activities)
|
|
};
|
|
|
|
for (var i = 0; i < activities.Length - 1; i++)
|
|
{
|
|
flowchart.Connections.Add(CreateConnection(activities[i], activities[i + 1]));
|
|
}
|
|
|
|
return flowchart;
|
|
}
|
|
|
|
public static Flowchart CreateBranchingFlowchart(IActivity start, IActivity branch1, IActivity branch2, IActivity? join = null)
|
|
{
|
|
var flowchart = new Flowchart
|
|
{
|
|
Start = start,
|
|
Activities = { start, branch1, branch2 }
|
|
};
|
|
|
|
flowchart.Connections.Add(CreateConnection(start, branch1));
|
|
flowchart.Connections.Add(CreateConnection(start, branch2));
|
|
|
|
if (join == null)
|
|
return flowchart;
|
|
|
|
flowchart.Activities.Add(join);
|
|
flowchart.Connections.Add(CreateConnection(branch1, join));
|
|
flowchart.Connections.Add(CreateConnection(branch2, join));
|
|
|
|
return flowchart;
|
|
}
|
|
}
|