forked from elsa-workflows/elsa-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add serialization tests and refactor serialization classes
Implemented new integration tests for serialization of programmatic workflows. Additionally, major refactoring was performed on the serialization classes. This involved moving the classes to new namespaces and enhancing their functionalities to correctly handle null inputs and to support the serialization of activities and expressions. Also, updated Elsa.sln.DotSettings and JsonActivitySerializer to handle new serializers.
- Loading branch information
1 parent
f71b8c3
commit fa44259
Showing
13 changed files
with
82 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ation/SerializationOptionsConfigurator.cs → ...izers/SerializationOptionsConfigurator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ntegration/Elsa.IntegrationTests/Serialization/ProgrammaticWorkflowsAndDelegates/Tests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Elsa.Extensions; | ||
using Elsa.Testing.Shared; | ||
using Elsa.Workflows.Contracts; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Elsa.IntegrationTests.Serialization.ProgrammaticWorkflowsAndDelegates; | ||
|
||
/// <summary> | ||
/// Contains tests for variable expressions serialization. | ||
/// </summary> | ||
public class Tests | ||
{ | ||
private readonly IActivitySerializer _activitySerializer; | ||
private readonly IWorkflowBuilder _workflowBuilder; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Tests"/> class. | ||
/// </summary> | ||
public Tests(ITestOutputHelper testOutputHelper) | ||
{ | ||
var serviceProvider = new TestApplicationBuilder(testOutputHelper).Build(); | ||
_activitySerializer = serviceProvider.GetRequiredService<IActivitySerializer>(); | ||
var workflowBuilderFactory = serviceProvider.GetRequiredService<IWorkflowBuilderFactory>(); | ||
_workflowBuilder = workflowBuilderFactory.CreateBuilder(); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that programmatic workflows with inputs using delegates do not throw exceptions when serialized. | ||
/// </summary> | ||
[Fact(DisplayName = "Programmatic workflows with inputs using delegates do not throw exceptions when serialized")] | ||
public async Task Test1() | ||
{ | ||
var workflow = await _workflowBuilder.BuildWorkflowAsync<GreeterWorkflow>(); | ||
var serializedWorkflow = _activitySerializer.Serialize(workflow); | ||
|
||
// If it reached here, the test passed | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...ration/Elsa.IntegrationTests/Serialization/ProgrammaticWorkflowsAndDelegates/Workflows.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using Elsa.Extensions; | ||
using Elsa.Workflows; | ||
using Elsa.Workflows.Activities; | ||
using Elsa.Workflows.Contracts; | ||
|
||
namespace Elsa.IntegrationTests.Serialization.ProgrammaticWorkflowsAndDelegates; | ||
|
||
/// <inheritdoc /> | ||
public class GreeterWorkflow : WorkflowBase | ||
{ | ||
/// <inheritdoc /> | ||
protected override void Build(IWorkflowBuilder builder) | ||
{ | ||
var messageInput = builder.WithInput<string>("Message", "The message to write to the console."); | ||
|
||
builder.Name = "Greeter Workflow"; | ||
builder.Inputs.Add(messageInput); | ||
builder.Root = new WriteLine(context => context.GetInput<string>(messageInput)); | ||
} | ||
} |