* Add unit and integration tests for `Container` activity, covering behavior such as variable scoping, child activity execution, and mixed variable types. * Refactor `RunWorkflowAndCaptureOutput` method in `ContainerTests` for better code organization * Move `Sequence` activity tests to a dedicated namespace and add new unit and integration tests for enhanced coverage. - Deleted outdated `SequenceTests` and related workflows. - Introduced `SequenceActivity` namespace with improved organization. - Added comprehensive unit and integration test coverage for sequential execution, nested sequences, conditional breaking, variables, and dynamic activities. * Relocate `SequenceActivity` tests to `Activities` namespace to improve organization and update references in related test classes. * Refactor `SequenceTests` to move `DynamicSequenceWorkflow` to its own file for better test organization. * Extract `TestContainer` to `Elsa.Testing.Shared.Activities` for reuse across test projects. * Add unit and integration tests for `Break` activity; refactor workflow tests for improved organization - Introduced `BreakInForkWorkflow` and deprecated `BreakWhileForkWorkflow`. - Added `BreakTests` unit tests to validate behavior of the `Break` activity, including terminal node implementation and execution completion. - Enhanced integration tests for `Break` activity, covering multiple looping constructs (`ForEach`, `For`, `While`, `Fork`) and nested workflows. - Updated `Fork` activity to handle the `BreakSignal` asynchronously. - Simplified workflow definitions by removing redundant constructors and using concise variable initialization syntax. - Improved test clarity with better organization, comments, and consistent naming conventions. * Refactor `Fork` activity tests and workflows for improved organization and coverage - Relocated `BasicForkWorkflow` and `JoinAnyForkWorkflow` to `Fork/Workflows` namespace. - Introduced `EmptyForkWorkflow` to test Fork behavior with no branches. - Enhanced `ForkTests` with scenarios for `Fork` execution with different join modes and branch configurations. - Refactored `Fork` activity to handle empty branches and simplified `BreakSignal` handling. - Improved consistency and clarity of test cases, including better assertions and comments. * Update test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/BreakTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/BreakTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Activities/Break/BreakTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Activities/Fork/ForkTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Workflows.IntegrationTests/Activities/Fork/ForkTests.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update GitHub Actions workflow to use .NET 10.x * Remove outdated GitHub workflows and update configurations to .NET 10.x * Remove unused result variable assignments in integration tests (#7105) * Initial plan * Remove unused result variable assignments in BreakTests and ForkTests Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
74 lines
2 KiB
C#
74 lines
2 KiB
C#
using Elsa.Testing.Shared;
|
|
using Elsa.Workflows;
|
|
|
|
namespace Elsa.Activities.UnitTests.Flow;
|
|
|
|
/// <summary>
|
|
/// Unit tests for the <see cref="Fork"/> activity.
|
|
/// </summary>
|
|
public class ForkTests
|
|
{
|
|
[Fact(DisplayName = "Fork schedules all branches")]
|
|
public async Task Fork_SchedulesAllBranches()
|
|
{
|
|
// Arrange
|
|
var branches = CreateBranches(3);
|
|
var fork = new Fork
|
|
{
|
|
JoinMode = ForkJoinMode.WaitAll,
|
|
Branches = branches.Cast<IActivity>().ToList()
|
|
};
|
|
|
|
// Act
|
|
var context = await ExecuteForkAsync(fork);
|
|
|
|
// Assert
|
|
foreach (var branch in branches)
|
|
{
|
|
Assert.True(context.HasScheduledActivity(branch), $"{branch.Id} should be scheduled");
|
|
}
|
|
}
|
|
|
|
[Fact(DisplayName = "Fork with no branches completes immediately")]
|
|
public async Task Fork_WithNoBranchesCompletesImmediately()
|
|
{
|
|
// Arrange
|
|
var fork = new Fork { JoinMode = ForkJoinMode.WaitAll };
|
|
|
|
// Act
|
|
var context = await ExecuteForkAsync(fork);
|
|
|
|
// Assert
|
|
Assert.Equal(ActivityStatus.Completed, context.Status);
|
|
}
|
|
|
|
[Theory(DisplayName = "Fork respects join mode")]
|
|
[InlineData(ForkJoinMode.WaitAll)]
|
|
[InlineData(ForkJoinMode.WaitAny)]
|
|
public async Task Fork_RespectsJoinMode(ForkJoinMode joinMode)
|
|
{
|
|
// Arrange
|
|
var branch = new WriteLine("Test Branch");
|
|
var fork = new Fork
|
|
{
|
|
JoinMode = joinMode,
|
|
Branches = { branch }
|
|
};
|
|
|
|
// Act
|
|
var context = await ExecuteForkAsync(fork);
|
|
|
|
// Assert
|
|
Assert.Equal(joinMode, fork.JoinMode);
|
|
Assert.True(context.HasScheduledActivity(branch));
|
|
}
|
|
|
|
private static Task<ActivityExecutionContext> ExecuteForkAsync(Fork fork) =>
|
|
new ActivityTestFixture(fork).ExecuteAsync();
|
|
|
|
private static WriteLine[] CreateBranches(int count) =>
|
|
Enumerable.Range(1, count)
|
|
.Select(i => new WriteLine($"Branch {i}") { Id = $"branch-{i}" })
|
|
.ToArray();
|
|
}
|