diff --git a/src/core/Elsa.Abstractions/Models/WorkflowPersistenceBehavior.cs b/src/core/Elsa.Abstractions/Models/WorkflowPersistenceBehavior.cs index e7881dea9..d0b1eea64 100644 --- a/src/core/Elsa.Abstractions/Models/WorkflowPersistenceBehavior.cs +++ b/src/core/Elsa.Abstractions/Models/WorkflowPersistenceBehavior.cs @@ -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. + + /// + /// Workflow instances are persisted after the workflow completed a burst of execution. + /// + WorkflowBurst = 0, + /// /// Workflow instances are persisted only when being suspended. /// Suspended, - /// - /// Workflow instances are persisted after the workflow completed a burst of execution. - /// - WorkflowBurst, - /// /// Workflow instances are persisted after the workflow executed scheduled activities. /// diff --git a/test/unit/Elsa.UnitTests/Services/WorkflowBuilderTests.cs b/test/unit/Elsa.UnitTests/Services/WorkflowBuilderTests.cs new file mode 100644 index 000000000..e38ec7990 --- /dev/null +++ b/test/unit/Elsa.UnitTests/Services/WorkflowBuilderTests.cs @@ -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) { } + } + } +} \ No newline at end of file