Move shared test utility to common folder + various incremental changes
This commit is contained in:
parent
8f53a12412
commit
3dfede96d3
21
Elsa.sln
21
Elsa.sln
|
|
@ -46,8 +46,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.IntegrationTests", "te
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.UnitTests", "test\Elsa.UnitTests\Elsa.UnitTests.csproj", "{85A6862B-E523-45FA-A26B-BF98BE140E89}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Testing.Shared", "test\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj", "{6B80C8AC-E9E7-43FD-B514-C0D801D15792}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Labels", "src\modules\Elsa.Labels\Elsa.Labels.csproj", "{80FF5821-E831-450D-AA0C-C76D07D878F4}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bundles", "bundles", "{F06B9573-DF68-4606-866C-A7546A10A05A}"
|
||||
|
|
@ -120,6 +118,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Email", "src\modules\E
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Workflows.Designer", "src\modules\Elsa.Workflows.Designer\Elsa.Workflows.Designer.csproj", "{B191F11D-583D-44D9-8A08-F5B0DC58B822}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Samples.HelloWorld", "src\samples\aspnet\Elsa.Samples.HelloWorld\Elsa.Samples.HelloWorld.csproj", "{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Testing.Shared", "src\common\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj", "{AD8C4BB0-C78F-496C-B326-1D82C02C7568}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -166,10 +168,6 @@ Global
|
|||
{85A6862B-E523-45FA-A26B-BF98BE140E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{85A6862B-E523-45FA-A26B-BF98BE140E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{85A6862B-E523-45FA-A26B-BF98BE140E89}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6B80C8AC-E9E7-43FD-B514-C0D801D15792}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6B80C8AC-E9E7-43FD-B514-C0D801D15792}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6B80C8AC-E9E7-43FD-B514-C0D801D15792}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6B80C8AC-E9E7-43FD-B514-C0D801D15792}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{80FF5821-E831-450D-AA0C-C76D07D878F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{80FF5821-E831-450D-AA0C-C76D07D878F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{80FF5821-E831-450D-AA0C-C76D07D878F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -306,6 +304,14 @@ Global
|
|||
{B191F11D-583D-44D9-8A08-F5B0DC58B822}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B191F11D-583D-44D9-8A08-F5B0DC58B822}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B191F11D-583D-44D9-8A08-F5B0DC58B822}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{155227F0-A33B-40AA-A4B4-06F813EB921B} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
|
||||
|
|
@ -315,7 +321,6 @@ Global
|
|||
{5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
|
||||
{B066ED0A-86E0-4025-85C2-7E8F7139D8A4} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
|
||||
{85A6862B-E523-45FA-A26B-BF98BE140E89} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
|
||||
{6B80C8AC-E9E7-43FD-B514-C0D801D15792} = {90031D64-CA0F-46D0-9AF4-8DC023A5FFCD}
|
||||
{F06B9573-DF68-4606-866C-A7546A10A05A} = {61017E64-6D00-49CB-9E81-5002DC8F7D5F}
|
||||
{448FCDE6-DE44-4E44-A1CC-B9AA51471121} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
{B2049499-D384-46DF-8837-F1180107DD54} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
|
|
@ -360,5 +365,7 @@ Global
|
|||
{555A4306-3BAB-409E-8BB8-3171A5867B2C} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
{1E5BD8D9-55BE-41E2-B389-6AB9F26C22AF} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
{B191F11D-583D-44D9-8A08-F5B0DC58B822} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79}
|
||||
{DF8CCA17-6B00-42C6-B4EC-61B42AA91EE0} = {56C2FFB8-EA54-45B5-A095-4A78142EB4B5}
|
||||
{AD8C4BB0-C78F-496C-B326-1D82C02C7568} = {C6658DE0-2B2F-47F0-BB61-2CA66D435C09}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
73
README.md
73
README.md
|
|
@ -22,13 +22,14 @@ Here are some of the more important features offered by Elsa:
|
|||
|
||||
- Execute workflows in any .NET app.
|
||||
- Supports both short-running and long-running workflows.
|
||||
- Programming model loosely inspired on WF4 (composable activities)
|
||||
- Support for complex activities such as Sequence and Flowchart.
|
||||
- Programming model loosely inspired on WF4 (composable activities).
|
||||
- Support for complex activities such as Sequence, Flowchart and custom composite activities (which are like mini-workflows that can be used as activities).
|
||||
- Ships with a workflows designer web component (currently supports Flowchart diagrams only).
|
||||
|
||||
## Examples
|
||||
## Console Examples
|
||||
|
||||
### Hello World
|
||||
|
||||
### Hello World: Console
|
||||
The following is a simple Hello World workflow created as a console application. The workflow is created using C#.
|
||||
|
||||
```csharp
|
||||
|
|
@ -60,4 +61,66 @@ Outputs:
|
|||
|
||||
```shell
|
||||
Hello World!
|
||||
```
|
||||
```
|
||||
|
||||
### Sequential workflows
|
||||
|
||||
To build workflows that execute more than one step, choose an activity that can do so. For example, the `Sequence` activity lets us add multiple activities to execute in sequence (plumbing code left out for brevity):
|
||||
|
||||
```csharp
|
||||
// Create a workflow.
|
||||
var workflow = new Sequence
|
||||
{
|
||||
Activities =
|
||||
{
|
||||
new WriteLine("Hello World!"),
|
||||
new WriteLine("Goodbye cruel world...")
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Outputs:
|
||||
|
||||
```shell
|
||||
Hello World!
|
||||
Goodbye cruel world...
|
||||
```
|
||||
|
||||
### Conditions
|
||||
|
||||
The following demonstrates a workflow where it asks the user to enter their age, and based on this, offers a beer or a soda:
|
||||
|
||||
```csharp
|
||||
// Declare a workflow variable for use in the workflow.
|
||||
var ageVariable = new Variable<string>();
|
||||
|
||||
// Declare a workflow.
|
||||
var workflow = new Sequence
|
||||
{
|
||||
// Register the variable.
|
||||
Variables = { ageVariable },
|
||||
|
||||
// Setup the sequence of activities to run.
|
||||
Activities =
|
||||
{
|
||||
new WriteLine("Please tell me your age:"),
|
||||
new ReadLine(ageVariable), // Stores user input into the provided variable.,
|
||||
new If
|
||||
{
|
||||
// If aged 18 or up, beer is provided, soda otherwise.
|
||||
Condition = new Input<bool>(context => ageVariable.Get<int>(context) < 18),
|
||||
Then = new WriteLine("Enjoy your soda!"),
|
||||
Else = new WriteLine("Enjoy your beer!")
|
||||
},
|
||||
new WriteLine("Come again!")
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
Notice that:
|
||||
|
||||
- To capture activity output, a workflow variable (ageVariable) is used.
|
||||
- Depending on the result of the condition of the `If` activity, either the `Then` or the `Else` activity is executed.
|
||||
- After the If activity completes, the final WriteLine activity is executed.
|
||||
|
||||
## ASP.NET Examples
|
||||
|
|
@ -63,9 +63,7 @@ services
|
|||
.UseLiquid()
|
||||
.UseHttp()
|
||||
.UseActivityDefinitions()
|
||||
)
|
||||
// Register FastEndpoints using collected assemblies from features.
|
||||
.AddFastEndpointsFromModule();
|
||||
);
|
||||
|
||||
services.AddHealthChecks();
|
||||
|
||||
|
|
@ -105,4 +103,5 @@ app.UseEndpoints(endpoints =>
|
|||
endpoints.MapFallbackToPage("/Index");
|
||||
});
|
||||
|
||||
app.MapRazorPages();
|
||||
app.Run();
|
||||
|
|
@ -77,7 +77,7 @@ services
|
|||
.UseJavaScript()
|
||||
.UseLiquid()
|
||||
.UseHttp()
|
||||
).AddFastEndpointsFromModule();
|
||||
);
|
||||
|
||||
services.AddHealthChecks();
|
||||
services.AddCors(cors => cors.AddDefaultPolicy(policy => policy.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin()));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props"/>
|
||||
<Import Project="..\..\configureawait.props"/>
|
||||
<Import Project="..\..\..\common.props" />
|
||||
<Import Project="..\..\..\configureawait.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
|
|
@ -12,12 +12,11 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3"/>
|
||||
<PackageReference Include="xunit.abstractions" Version="2.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\bundles\Elsa\Elsa.csproj"/>
|
||||
<ProjectReference Include="..\..\src\modules\Elsa.Workflows.Core\Elsa.Workflows.Core.csproj"/>
|
||||
<ProjectReference Include="..\..\bundles\Elsa\Elsa.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -34,7 +34,7 @@ public class HttpFeature : FeatureBase
|
|||
typeof(HttpRequestHeaders),
|
||||
typeof(HttpRequestModel),
|
||||
typeof(HttpResponseModel)
|
||||
}, "HTTP"));
|
||||
}, "HTTP").AddActivitiesFrom<HttpFeature>());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
|
|
|||
|
|
@ -19,4 +19,10 @@ public class WorkflowsApiFeature : FeatureBase
|
|||
{
|
||||
Module.AddFastEndpointsAssembly(GetType());
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Apply()
|
||||
{
|
||||
Module.AddFastEndpointsFromModule();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\bundles\Elsa\Elsa.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Http\Elsa.Http.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Identity\Elsa.Identity.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.JavaScript\Elsa.JavaScript.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Jobs.Activities\Elsa.Jobs.Activities.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Liquid\Elsa.Liquid.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Persistence.EntityFrameworkCore.Sqlite\Elsa.Persistence.EntityFrameworkCore.Sqlite.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Persistence.EntityFrameworkCore\Elsa.Persistence.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.ProtoActor\Elsa.ProtoActor.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Scheduling\Elsa.Scheduling.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Telnyx\Elsa.Telnyx.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.WorkflowContexts\Elsa.WorkflowContexts.csproj" />
|
||||
<ProjectReference Include="..\..\..\modules\Elsa.Workflows.Api\Elsa.Workflows.Api.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
27
src/samples/aspnet/Elsa.Samples.HelloWorld/Program.cs
Normal file
27
src/samples/aspnet/Elsa.Samples.HelloWorld/Program.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Elsa.Extensions;
|
||||
using Elsa.Http.Extensions;
|
||||
using Elsa.Workflows.Management.Extensions;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var services = builder.Services;
|
||||
|
||||
// Add Elsa services.
|
||||
services.AddElsa(elsa => elsa
|
||||
|
||||
.UseWorkflowManagement()
|
||||
|
||||
// Enable Elsa HTTP module (for HTTP related activities).
|
||||
.UseHttp()
|
||||
);
|
||||
|
||||
// Configure middleware pipeline.
|
||||
var app = builder.Build();
|
||||
|
||||
if (app.Environment.IsDevelopment())
|
||||
app.UseDeveloperExceptionPage();
|
||||
|
||||
// Add Elsa HTTP middleware (to handle requests mapped to HTTP Endpoint activities)
|
||||
app.UseHttpActivities();
|
||||
|
||||
// Run.
|
||||
app.Run();
|
||||
|
|
@ -21,8 +21,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\common\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj" />
|
||||
<ProjectReference Include="..\..\src\modules\Elsa.Workflows.Runtime\Elsa.Workflows.Runtime.csproj" />
|
||||
<ProjectReference Include="..\Elsa.Testing.Shared\Elsa.Testing.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
Loading…
Reference in a new issue