Add project files.
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
using Elsa.Testing.Shared;
|
||||
using Elsa.Workflows.IncidentStrategies;
|
||||
using Elsa.Workflows.IntegrationTests.Scenarios.Incidents.Statics;
|
||||
using Elsa.Workflows.IntegrationTests.Scenarios.Incidents.Workflows;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace Elsa.Workflows.IntegrationTests.Scenarios.Incidents;
|
||||
|
||||
public class IncidentStrategyTests
|
||||
{
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly CapturingTextWriter _capturingTextWriter = new();
|
||||
|
||||
public IncidentStrategyTests(ITestOutputHelper testOutputHelper)
|
||||
{
|
||||
_services = new TestApplicationBuilder(testOutputHelper)
|
||||
.WithCapturingTextWriter(_capturingTextWriter)
|
||||
.AddWorkflow<FaultyWorkflow>()
|
||||
.Build();
|
||||
}
|
||||
|
||||
[Theory(DisplayName = "Workflows with a Fault strategy do not continue after a fault")]
|
||||
[InlineData(typeof(FaultStrategy), new[] { "Start", "Step 1a", "Step 2a" }, WorkflowSubStatus.Faulted)]
|
||||
[InlineData(typeof(ContinueWithIncidentsStrategy), new[] { "Start", "Step 1a", "Step 2a", "Step 1b" }, WorkflowSubStatus.Suspended)]
|
||||
public async Task Test0(Type incidentStrategyType, string[] expectedOutput, WorkflowSubStatus expectedSubStatus)
|
||||
{
|
||||
TestSettings.IncidentStrategyType = incidentStrategyType;
|
||||
await _services.PopulateRegistriesAsync();
|
||||
var workflowState = await _services.RunWorkflowUntilEndAsync<FaultyWorkflow>();
|
||||
var lines = _capturingTextWriter.Lines.ToList();
|
||||
Assert.Equal(expectedOutput, lines);
|
||||
Assert.Equal(expectedSubStatus, workflowState.SubStatus);
|
||||
Assert.Equal(1, workflowState.Incidents.Count);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
using Elsa.Workflows.IncidentStrategies;
|
||||
|
||||
namespace Elsa.Workflows.IntegrationTests.Scenarios.Incidents.Statics;
|
||||
|
||||
public static class TestSettings
|
||||
{
|
||||
public static Type IncidentStrategyType { get; set; } = typeof(FaultStrategy);
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
using Elsa.Workflows.Activities;
|
||||
using Elsa.Workflows.Activities.Flowchart.Activities;
|
||||
using Elsa.Workflows.Activities.Flowchart.Models;
|
||||
using Elsa.Workflows.IntegrationTests.Scenarios.Incidents.Statics;
|
||||
using Elsa.Workflows.Runtime.Activities;
|
||||
|
||||
namespace Elsa.Workflows.IntegrationTests.Scenarios.Incidents.Workflows;
|
||||
|
||||
public class FaultyWorkflow : WorkflowBase
|
||||
{
|
||||
protected override void Build(IWorkflowBuilder builder)
|
||||
{
|
||||
var start = new WriteLine("Start");
|
||||
var step1A = new WriteLine("Step 1a");
|
||||
var event1 = new Event("Event 1");
|
||||
var step1B = new WriteLine("Step 1b");
|
||||
var step2A = new WriteLine("Step 2a");
|
||||
var event2 = new Event("Event 2");
|
||||
var step2B = new WriteLine("Step 2b");
|
||||
var fault = Fault.Create("Whoops!", "Test", "Test");
|
||||
|
||||
builder.WorkflowOptions.IncidentStrategyType = TestSettings.IncidentStrategyType;
|
||||
|
||||
builder.Root = new Flowchart
|
||||
{
|
||||
Activities =
|
||||
{
|
||||
start,
|
||||
step1A,
|
||||
event1,
|
||||
step1B,
|
||||
step2A,
|
||||
event2,
|
||||
step2B,
|
||||
fault
|
||||
},
|
||||
|
||||
Connections = new[]
|
||||
{
|
||||
new Connection(start, step1A),
|
||||
new Connection(step1A, event1),
|
||||
new Connection(event1, step1B),
|
||||
|
||||
new Connection(start, step2A),
|
||||
new Connection(step2A, fault),
|
||||
new Connection(fault, event2),
|
||||
new Connection(event2, step2B),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user