elsa-core/test/integration/Elsa.Activities.IntegrationTests/ForEachTests.cs
Sipke Schoorstra bdfbd0886f
Add ForEach tests, introduce asynchronous workflow runner and enhance workflow events. (#6926)
* Introduce asynchronous workflow runner and enhance workflow events.

- Added `AsyncWorkflowRunner` to enable asynchronous workflow execution and result tracking.
- Introduced new event arguments, such as `ActivityExecutedEventArgs` and `WorkflowStateCommittedEventArgs`.
- Expanded `WorkflowEvents` class to include `ActivityExecuted`, `ActivityExecutedLogUpdated`, and `WorkflowStateCommitted` events.
- Refactored event arguments into the `Elsa.Testing.Shared.EventArgs` namespace.
- Enhanced tests with `AsyncWorkflowRunner` and new event-driven workflow scenarios.

* Refactor event argument classes to unify namespace and simplify inheritance

* Add shared component DotSettings file to support namespace exclusions
2025-09-24 20:06:00 +02:00

29 lines
1 KiB
C#

using Elsa.Extensions;
using Elsa.Testing.Shared;
using Elsa.Workflows.Activities;
using Xunit.Abstractions;
namespace Elsa.Activities.IntegrationTests;
public class ForEachTests
{
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _serviceProvider;
public ForEachTests(ITestOutputHelper testOutputHelper)
{
_serviceProvider = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
}
[Fact(DisplayName = "ForEach executes each activity for every item in the collection")]
public async Task ForEach_ExecutesEachActivity_ForEveryItem()
{
var expectedLines = new[] {"a", "b", "c"};
var forEach = new ForEach<string>(expectedLines)
{
Body = new WriteLine(context => context.GetVariable<string>("CurrentValue"))
};
await _serviceProvider.RunActivityAsync(forEach);
Assert.Equal(expectedLines, _capturingTextWriter.Lines);
}
}