elsa-core/test/integration/Elsa.Activities.IntegrationTests/Composition/CompleteTests.cs
Sipke Schoorstra 8700036123
Add unit and integration tests for Complete activity to validate composite workflows execution (#7108)
* Add unit and integration tests for `Complete` activity to validate composite workflows execution

- Introduced integration and unit tests covering `Complete` activity behavior in nested and simple composite workflows.
- Added `CompleteTests` for edge cases such as immediate parent completion and composite termination.
- Developed new composite activities (`InnerComposite`, `OuterComposite`, `SimpleComposite`) for testing scenarios.

* Remove unnecessary `Complete` constructors tests.
2025-11-26 12:26:31 +01:00

47 lines
1.9 KiB
C#

using Elsa.Activities.IntegrationTests.Composition.Workflows;
using Elsa.Testing.Shared;
using Elsa.Workflows;
using Elsa.Workflows.Activities;
using Xunit.Abstractions;
namespace Elsa.Activities.IntegrationTests.Composition;
/// <summary>
/// Integration tests for the <see cref="Complete"/> activity.
/// </summary>
public class CompleteTests(ITestOutputHelper testOutputHelper)
{
private readonly WorkflowTestFixture _fixture = new WorkflowTestFixture(testOutputHelper)
.AddWorkflow<CompleteTerminatesCompositeWorkflow>()
.AddWorkflow<CompleteInNestedCompositeWorkflow>();
[Fact(DisplayName = "Complete terminates composite execution immediately")]
public async Task Complete_TerminatesCompositeExecutionImmediately()
{
// Act
var workflowState = await _fixture.RunWorkflowAsync(CompleteTerminatesCompositeWorkflow.DefinitionId);
// Assert
Assert.Equal(WorkflowStatus.Finished, workflowState.Status);
var lines = _fixture.CapturingTextWriter.Lines.ToList();
Assert.Contains("Before Complete", lines);
Assert.DoesNotContain("This should not execute", lines);
Assert.Contains("After composite", lines);
}
[Fact(DisplayName = "Complete in nested composite completes immediate parent only")]
public async Task Complete_InNestedComposite_CompletesImmediateParentOnly()
{
// Act
var workflowState = await _fixture.RunWorkflowAsync(CompleteInNestedCompositeWorkflow.DefinitionId);
// Assert
Assert.Equal(WorkflowStatus.Finished, workflowState.Status);
var lines = _fixture.CapturingTextWriter.Lines.ToList();
Assert.Contains("Outer composite started", lines);
Assert.Contains("Inner composite started", lines);
Assert.Contains("Inner composite completed", lines);
Assert.Contains("Outer composite completed", lines);
Assert.DoesNotContain("This should not execute in inner", lines);
}
}