elsa-core/test/unit/Elsa.Bpmn.UnitTests/BpmnProcessDescriptorTests.cs
Sipke Schoorstra e54ced5662
feat(bpmn): declare BpmnProcess's Done and Cancelled outcomes as flow ports (#8066)
Elsa.Bpmn.Activities.BpmnProcess completed with the interpreter's Done or
Cancelled outcome but declared no outcomes, so a Flowchart composing it only
saw Studio's synthesized default port and the Cancelled outcome was
unreachable. Declares both via [FlowNode(BpmnInterpreter.DoneOutcomeName,
BpmnInterpreter.CancelledOutcomeName)] (both const in Bpmn.Semantics 0.2.0),
adds a descriptor test asserting the two flow ports, and a composition test
routing a cancelled transaction down the Cancelled port.

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
2026-09-11 23:16:21 -07:00

35 lines
1.4 KiB
C#

using System.Reflection;
using Bpmn.Semantics;
using Elsa.Bpmn.Activities;
using Elsa.Workflows;
using Elsa.Workflows.Models;
using NSubstitute;
using Xunit;
namespace Elsa.Bpmn.UnitTests;
public class BpmnProcessDescriptorTests
{
[Fact(DisplayName = "BpmnProcess's descriptor declares Done and Cancelled as its only flow ports")]
public async Task DescribeActivityAsync_DeclaresDoneAndCancelledAsOnlyFlowPorts()
{
var defaultValueResolver = Substitute.For<IPropertyDefaultValueResolver>();
var propertyUIHandlerResolver = Substitute.For<IPropertyUIHandlerResolver>();
defaultValueResolver.GetDefaultValue(Arg.Any<PropertyInfo>()).Returns((object?)null);
propertyUIHandlerResolver
.GetUIPropertiesAsync(Arg.Any<PropertyInfo>(), Arg.Any<object?>(), Arg.Any<CancellationToken>())
.Returns(_ => new ValueTask<IDictionary<string, object>>(new Dictionary<string, object>()));
var describer = new ActivityDescriber(defaultValueResolver, propertyUIHandlerResolver);
var descriptor = await describer.DescribeActivityAsync(typeof(BpmnProcess));
var flowPorts = descriptor.Ports.Where(port => port.Type == PortType.Flow).ToList();
Assert.Equal(2, flowPorts.Count);
Assert.Contains(flowPorts, port => port.Name == BpmnInterpreter.DoneOutcomeName);
Assert.Contains(flowPorts, port => port.Name == BpmnInterpreter.CancelledOutcomeName);
}
}