* Remove unused using directives in test classes The using directives for System, System.Collections.Generic, System.IO, and others were not necessary in many of the test classes. These unused directives have been removed to enhance code readability and maintainability. * Update source port retrieval in ConnectionJsonConverter The source port retrieval code in ConnectionJsonConverter.cs has been updated. It now uses TryGetProperty instead of GetProperty, enabling it to handle cases where the "port" property may not exist. This enhances error handling and resilience in the activities module. * Refactor InputJsonConverter for proper variable expressions handling The InputJsonConverter in the Elsa.Workflows.Serialization has been expanded for efficient handling of variable expressions during the JSON conversion process. The refactor ensures appropriate extraction and assignment of values to variables. This adds robustness to the serialization process, maintaining variable types after serialization. * Add tests for variable expressions serialization A new `Tests.cs` file has been added under the `Elsa.IntegrationTests/Serialization/VariableExpressions` directory. This file contains tests for ensuring the serialization of variable expressions works correctly. A corresponding `SampleWorkflow` file has also been established, providing the workflows to be used in the tests. * Refactor workflow builder extension class The WorkflowDefinitionBuilderExtensions class has been deleted and replaced with WorkflowBuilderExtensions in Elsa.Workflows.Core. This new class retains similar functionality but includes more detailed comments and dynamic member access capabilities in its method definition.
37 lines
1.6 KiB
C#
37 lines
1.6 KiB
C#
using Elsa.IntegrationTests.Scenarios.Incidents.Statics;
|
|
using Elsa.IntegrationTests.Scenarios.Incidents.Workflows;
|
|
using Elsa.Testing.Shared;
|
|
using Elsa.Workflows;
|
|
using Elsa.Workflows.IncidentStrategies;
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace Elsa.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);
|
|
}
|
|
} |