WIP #728 - Make WorkflowBurst default behaviour

In the comments to #728 it was suggested that
WorkflowBurst persistence behaviour was a more
sane default.
This commit is contained in:
Craig Fowler 2021-03-09 19:52:36 +00:00
parent 32bcf9a751
commit 8751bead5a
2 changed files with 40 additions and 5 deletions

View file

@ -6,16 +6,22 @@ namespace Elsa.Models
[JsonConverter(typeof(StringEnumConverter))]
public enum WorkflowPersistenceBehavior
{
// TODO: Consider a new service to "get the default persistence behaviour".
// Currently it is set to WorkflowBurst implicitly because it is the default
// for the enum type. This would be more clear if explicit.
// This includes altering all locations which need a default persistence
// behaviour though.
/// <summary>
/// Workflow instances are persisted after the workflow completed a burst of execution.
/// </summary>
WorkflowBurst = 0,
/// <summary>
/// Workflow instances are persisted only when being suspended.
/// </summary>
Suspended,
/// <summary>
/// Workflow instances are persisted after the workflow completed a burst of execution.
/// </summary>
WorkflowBurst,
/// <summary>
/// Workflow instances are persisted after the workflow executed scheduled activities.
/// </summary>

View file

@ -0,0 +1,29 @@
using System;
using AutoFixture.Xunit2;
using Elsa.Builders;
using Elsa.Models;
using Elsa.Testing.Shared.AutoFixture.Attributes;
using Xunit;
namespace Elsa.Services
{
public class WorkflowBuilderTests
{
[Theory(DisplayName = "The Build method should return a workflow blueprint with the WorkflowBurst persistence behaviour if no behaviour was specified"), AutoMoqData]
public void BuildShouldReturnWorkflowBlueprintWithWorkflowBurstPersistenceBehaviourIfNoBehaviourSpecified([AutofixtureServiceProvider, Frozen] IServiceProvider serviceProvider,
WorkflowBuilder sut,
string idPrefix)
{
var workflow = new NoOpWorkflow();
var blueprint = sut.Build(workflow, idPrefix);
Assert.Equal(WorkflowPersistenceBehavior.WorkflowBurst, blueprint.PersistenceBehavior);
}
class NoOpWorkflow : IWorkflow
{
public void Build(IWorkflowBuilder builder) { }
}
}
}