Add project files.

This commit is contained in:
2025-08-18 17:11:43 +03:30
parent 807dc263be
commit e5eb10d604
3943 changed files with 223719 additions and 0 deletions
@@ -0,0 +1,36 @@
using Elsa.Testing.Shared;
using Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins.Workflows;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Abstractions;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins;
public class BraidedWorkflowTests
{
private readonly IWorkflowRunner _workflowRunner;
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _services;
public BraidedWorkflowTests(ITestOutputHelper testOutputHelper)
{
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
_workflowRunner = _services.GetRequiredService<IWorkflowRunner>();
}
[Fact(DisplayName = "Braided workflows are executed correctly")]
public async Task Test1()
{
await _services.PopulateRegistriesAsync();
await _workflowRunner.RunAsync<BraidedWorkflow>();
var lines = _capturingTextWriter.Lines.ToList();
Assert.Equal(new[] { "WriteLine1", "WriteLine2", "WriteLine3", "WriteLine4", "WriteLine5", "WriteLine6", "WriteLine7" }, lines);
}
[Fact(DisplayName = "Braided workflows complete the workflow")]
public async Task Test2()
{
await _services.PopulateRegistriesAsync();
var result = await _workflowRunner.RunAsync<BraidedWorkflow>();
Assert.Equal(WorkflowStatus.Finished, result.WorkflowState.Status);
}
}
@@ -0,0 +1,36 @@
using Elsa.Testing.Shared;
using Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins.Workflows;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Abstractions;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins;
public class ImplicitWorkflowTests
{
private readonly IWorkflowRunner _workflowRunner;
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _services;
public ImplicitWorkflowTests(ITestOutputHelper testOutputHelper)
{
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
_workflowRunner = _services.GetRequiredService<IWorkflowRunner>();
}
[Fact(DisplayName = "Implicit loop workflows are executed correctly")]
public async Task Test1()
{
await _services.PopulateRegistriesAsync();
await _workflowRunner.RunAsync<ImplicitLoopWorkflow>();
var lines = _capturingTextWriter.Lines.ToList();
Assert.Equal(new[] { "Start", "Retry", "End" }, lines);
}
[Fact(DisplayName = "Implicit loop workflows complete the workflow")]
public async Task Test2()
{
await _services.PopulateRegistriesAsync();
var result = await _workflowRunner.RunAsync<ImplicitLoopWorkflow>();
Assert.Equal(WorkflowStatus.Finished, result.WorkflowState.Status);
}
}
@@ -0,0 +1,42 @@
using Elsa.Common.Models;
using Elsa.Testing.Shared;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Filters;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Abstractions;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins;
public class JoinRunsOnceTests
{
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _services;
public JoinRunsOnceTests(ITestOutputHelper testOutputHelper)
{
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
}
[Fact(DisplayName = "The Join activity executes only once, not twice")]
public async Task Test1()
{
// Populate registries.
await _services.PopulateRegistriesAsync();
// Import workflow.
var workflowDefinition = await _services.ImportWorkflowDefinitionAsync($"Scenarios/ImplicitJoins/Workflows/join.json");
// Execute.
var state = await _services.RunWorkflowUntilEndAsync(workflowDefinition.DefinitionId);
// Assert.
var journal = await _services.GetRequiredService<IWorkflowExecutionLogStore>().FindManyAsync(new WorkflowExecutionLogRecordFilter
{
WorkflowInstanceId = state.Id,
ActivityId = "802725996be1b582",
EventName = "Completed"
}, PageArgs.All);
Assert.Single(journal.Items);
}
}
@@ -0,0 +1,42 @@
using Elsa.Common.Models;
using Elsa.Testing.Shared;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Filters;
using Microsoft.Extensions.DependencyInjection;
using Xunit.Abstractions;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins;
public class ParallelJoinCompletesTests
{
private readonly CapturingTextWriter _capturingTextWriter = new();
private readonly IServiceProvider _services;
public ParallelJoinCompletesTests(ITestOutputHelper testOutputHelper)
{
_services = new TestApplicationBuilder(testOutputHelper).WithCapturingTextWriter(_capturingTextWriter).Build();
}
[Fact(DisplayName = "The ParallelForEach activity completes when its Body contains a Join activity")]
public async Task Test1()
{
// Populate registries.
await _services.PopulateRegistriesAsync();
// Import workflow.
var workflowDefinition = await _services.ImportWorkflowDefinitionAsync("Scenarios/ImplicitJoins/Workflows/parallel-join.json");
// Execute.
var state = await _services.RunWorkflowUntilEndAsync(workflowDefinition.DefinitionId);
// Assert.
var journal = await _services.GetRequiredService<IWorkflowExecutionLogStore>().FindManyAsync(new()
{
WorkflowInstanceId = state.Id,
ActivityId = "70fc1183cd5800f2",
EventName = "Completed"
}, PageArgs.All);
Assert.Single(journal.Items);
}
}
@@ -0,0 +1,51 @@
using Elsa.Workflows.Activities;
using Elsa.Workflows.Activities.Flowchart.Activities;
using Elsa.Workflows.Activities.Flowchart.Models;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins.Workflows;
public class BraidedWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder workflow)
{
var writeLine1 = new WriteLine("WriteLine1");
var writeLine2 = new WriteLine("WriteLine2");
var writeLine3 = new WriteLine("WriteLine3");
var writeLine4 = new WriteLine("WriteLine4");
var writeLine5 = new WriteLine("WriteLine5");
var writeLine6 = new WriteLine("WriteLine6");
var writeLine7 = new WriteLine("WriteLine7");
workflow.Root = new Flowchart
{
Start = writeLine1,
Activities =
{
writeLine1,
writeLine2,
writeLine3,
writeLine4,
writeLine5,
writeLine6,
writeLine7,
},
Connections =
{
new Connection(writeLine1, writeLine2),
new Connection(writeLine1, writeLine3),
new Connection(writeLine2, writeLine4),
new Connection(writeLine2, writeLine5),
new Connection(writeLine3, writeLine5),
new Connection(writeLine3, writeLine6),
new Connection(writeLine4, writeLine7),
new Connection(writeLine5, writeLine7),
new Connection(writeLine6, writeLine7),
}
};
}
}
@@ -0,0 +1,41 @@
using Elsa.Workflows.Activities;
using Elsa.Workflows.Activities.Flowchart.Activities;
using Elsa.Workflows.Activities.Flowchart.Models;
namespace Elsa.Workflows.IntegrationTests.Scenarios.ImplicitJoins.Workflows;
public class ImplicitLoopWorkflow : WorkflowBase
{
protected override void Build(IWorkflowBuilder builder)
{
var counterVariable = builder.WithVariable(0);
var start = new WriteLine("Start");
var incrementCounter = new SetVariable<int>(counterVariable, context => counterVariable.Get(context) + 1);
var counterGreaterThanOne = new FlowDecision(context => counterVariable.Get(context) > 1);
var retry = new WriteLine("Retry");
var end = new WriteLine("End");
builder.Root = new Flowchart
{
Start = start,
Activities =
{
start,
incrementCounter,
counterGreaterThanOne,
retry,
end
},
Connections =
{
new Connection(start, incrementCounter),
new Connection(incrementCounter, counterGreaterThanOne),
new Connection(new Endpoint(counterGreaterThanOne, "False"), new Endpoint(retry)),
new Connection(new Endpoint(counterGreaterThanOne, "True"), new Endpoint(end)),
new Connection(retry, incrementCounter),
}
};
}
}
@@ -0,0 +1,215 @@
{
"id": "825e9d347e2f3094",
"definitionId": "f64e42304661f407",
"name": "Joins",
"createdAt": "2023-12-13T21:41:53.628415+00:00",
"version": 3,
"toolVersion": "3.0.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {
"Elsa:WorkflowContextProviderTypes": []
},
"isReadonly": false,
"isLatest": true,
"isPublished": false,
"options": {
"autoUpdateConsumingWorkflows": false
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "8a03bf79d15fd48a",
"nodeId": "Workflow1:8a03bf79d15fd48a",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"id": "c7624645ff77c7d0",
"nodeId": "Workflow1:8a03bf79d15fd48a:c7624645ff77c7d0",
"name": "Start1",
"type": "Elsa.Start",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -400.5,
"y": 212
},
"size": {
"width": 102.21875,
"height": 50
}
}
}
},
{
"text": null,
"id": "281e9ea6d278b231",
"nodeId": "Workflow1:8a03bf79d15fd48a:281e9ea6d278b231",
"name": "WriteLine2",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -160.5,
"y": 305
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"mode": {
"typeName": "Elsa.Workflows.Core.Activities.Flowchart.Models.FlowJoinMode, Elsa.Workflows.Core",
"expression": {
"type": "Literal",
"value": "WaitAny"
},
"memoryReference": {
"id": "802725996be1b582:input-0"
}
},
"id": "802725996be1b582",
"nodeId": "Workflow1:8a03bf79d15fd48a:802725996be1b582",
"name": "FlowJoin1",
"type": "Elsa.FlowJoin",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 80,
"y": 200
},
"size": {
"width": 98.265625,
"height": 50
}
}
}
},
{
"text": null,
"id": "bfc88f064cf394ed",
"nodeId": "Workflow1:8a03bf79d15fd48a:bfc88f064cf394ed",
"name": "WriteLine1",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -160,
"y": 120
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"id": "5467123c7973d011",
"nodeId": "Workflow1:8a03bf79d15fd48a:5467123c7973d011",
"name": "End1",
"type": "Elsa.End",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 274.5,
"y": 200
},
"size": {
"width": 94.40625,
"height": 50
}
}
}
}
],
"connections": [
{
"source": {
"activity": "c7624645ff77c7d0",
"port": "Done"
},
"target": {
"activity": "bfc88f064cf394ed",
"port": "In"
}
},
{
"source": {
"activity": "bfc88f064cf394ed",
"port": "Done"
},
"target": {
"activity": "802725996be1b582",
"port": "In"
}
},
{
"source": {
"activity": "c7624645ff77c7d0",
"port": "Done"
},
"target": {
"activity": "281e9ea6d278b231",
"port": "In"
}
},
{
"source": {
"activity": "281e9ea6d278b231",
"port": "Done"
},
"target": {
"activity": "802725996be1b582",
"port": "In"
}
},
{
"source": {
"activity": "802725996be1b582",
"port": "Done"
},
"target": {
"activity": "5467123c7973d011",
"port": "In"
}
}
]
}
}
@@ -0,0 +1,241 @@
{
"id": "2effd8f5f4205a5b",
"definitionId": "2da8d4cb0fcfbacd",
"name": "Parallel \u002B Join",
"createdAt": "2023-12-13T21:42:12.634042+00:00",
"version": 2,
"toolVersion": "3.0.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {
"Elsa:WorkflowContextProviderTypes": []
},
"isReadonly": false,
"isLatest": true,
"isPublished": false,
"options": {
"autoUpdateConsumingWorkflows": false
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "d3350290ed96e720",
"nodeId": "Workflow1:d3350290ed96e720",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"items": {
"typeName": "Object[]",
"expression": {
"type": "JavaScript",
"value": "[1,2,3]"
},
"memoryReference": {
"id": "70fc1183cd5800f2:input-0"
}
},
"body": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "b07170f2d68980cd",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2:b07170f2d68980cd",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"condition": {
"typeName": "Boolean",
"expression": {
"type": "JavaScript",
"value": "false"
},
"memoryReference": {
"id": "33665f061d96b957:input-0"
}
},
"id": "33665f061d96b957",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2:b07170f2d68980cd:33665f061d96b957",
"name": "FlowDecision1",
"type": "Elsa.FlowDecision",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -329.140625,
"y": -78.5
},
"size": {
"width": 129.515625,
"height": 50
}
}
}
},
{
"text": null,
"id": "e27177eb5965bd6b",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2:b07170f2d68980cd:e27177eb5965bd6b",
"name": "WriteLine1",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -40,
"y": -160
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": null,
"id": "343d233a75d8d8e9",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2:b07170f2d68980cd:343d233a75d8d8e9",
"name": "WriteLine2",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 371.859375,
"y": -78.5
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"mode": {
"typeName": "Elsa.Workflows.Core.Activities.Flowchart.Models.FlowJoinMode, Elsa.Workflows.Core",
"expression": {
"type": "Literal",
"value": "WaitAny"
},
"memoryReference": {
"id": "1f8625e278b74aa3:input-0"
}
},
"id": "1f8625e278b74aa3",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2:b07170f2d68980cd:1f8625e278b74aa3",
"name": "FlowJoin1",
"type": "Elsa.FlowJoin",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 188.859375,
"y": -78.5
},
"size": {
"width": 98.265625,
"height": 50
}
}
}
}
],
"connections": [
{
"source": {
"activity": "33665f061d96b957",
"port": "True"
},
"target": {
"activity": "e27177eb5965bd6b",
"port": "In"
}
},
{
"source": {
"activity": "e27177eb5965bd6b",
"port": "Done"
},
"target": {
"activity": "1f8625e278b74aa3",
"port": "In"
}
},
{
"source": {
"activity": "1f8625e278b74aa3",
"port": "Done"
},
"target": {
"activity": "343d233a75d8d8e9",
"port": "In"
}
},
{
"source": {
"activity": "33665f061d96b957",
"port": "False"
},
"target": {
"activity": "1f8625e278b74aa3",
"port": "In"
}
}
]
},
"id": "70fc1183cd5800f2",
"nodeId": "Workflow1:d3350290ed96e720:70fc1183cd5800f2",
"name": "ParallelForEach1",
"type": "Elsa.ParallelForEach",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -260,
"y": 140
},
"size": {
"width": 185.203125,
"height": 116.015625
}
}
}
}
],
"connections": []
}
}