Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/WorkflowCore.DSL/Services/DefinitionLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void acn(IStepBody pStep, object pData, IStepExecutionContext pContext)
stack.Push(child);
}

stepProperty.SetValue(pStep, destObj);
stepProperty.SetValue(pStep, destObj.ToObject(stepProperty.PropertyType));
}
return acn;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,23 @@ public void should_execute_json_workflow_with_dynamic_data()
data["Counter6"].Should().Be(1);
data["Counter10"].Should().Be(1);
}


[Fact]
public void should_execute_json_workflow_with_complex_input_type()
{
var initialData = new FlowData();
var workflowId = StartWorkflow(TestAssets.Utils.GetTestDefinitionJsonComplexInputProperty(), initialData);
WaitForWorkflowToComplete(workflowId, TimeSpan.FromSeconds(30));

var data = GetData<FlowData>(workflowId);
GetStatus(workflowId).Should().Be(WorkflowStatus.Complete);
UnhandledStepErrors.Count.Should().Be(0);
data.Assignee.Should().NotBeNull();
data.Assignee.Name.Should().Be("John Doe");
data.Assignee.UnitInfo.Should().NotBeNull();
data.Assignee.UnitInfo.Name.Should().Be("IT Department");

}
}
}
10 changes: 10 additions & 0 deletions test/WorkflowCore.TestAssets/DataTypes/FlowData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Linq;
using WorkflowCore.TestAssets.Steps;

namespace WorkflowCore.TestAssets.DataTypes;

public class FlowData
{
public AssigneeInfo Assignee { get; set; } = new();
}
27 changes: 27 additions & 0 deletions test/WorkflowCore.TestAssets/Steps/AssignTask.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;
using System.Linq;
using WorkflowCore.Interface;
using WorkflowCore.Models;
using WorkflowCore.TestAssets.DataTypes;

namespace WorkflowCore.TestAssets.Steps;

public class AssignTask : StepBody
{
public AssigneeInfo Assignee { get; set; }

public override ExecutionResult Run(IStepExecutionContext context)
{
if (context.Workflow.Data is FlowData flowData)
{
flowData.Assignee = new AssigneeInfo
{
Id = Assignee.Id,
Name = Assignee.Name,
MemberType = Assignee.MemberType,
UnitInfo = Assignee.UnitInfo
};
}
return ExecutionResult.Next();
}
}
20 changes: 20 additions & 0 deletions test/WorkflowCore.TestAssets/Steps/AssigneeInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Linq;

namespace WorkflowCore.TestAssets.Steps;

public class AssigneeInfo
{
public int Id { get; set; }
public string Name { get; set; }
public int MemberType { get; set; }

public UnitInfo UnitInfo { get; set; }
}

public class UnitInfo
{
public int Id { get; set; }
public string Name { get; set; }
public int UnitType { get; set; }
}
6 changes: 6 additions & 0 deletions test/WorkflowCore.TestAssets/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public static string GetTestDefinitionJsonMissingInputProperty()
{
return File.ReadAllText("stored-def-missing-input-property.json");
}


public static string GetTestDefinitionJsonComplexInputProperty()
{
return File.ReadAllText("def-complex-input-property.json");
}
}
}

4 changes: 4 additions & 0 deletions test/WorkflowCore.TestAssets/WorkflowCore.TestAssets.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<None Remove="stored-definition.yaml" />
<None Remove="stored-dynamic-definition.json" />
<None Remove="stored-dynamic-definition.yaml" />
<None Remove="def-complex-input-property.json" />
</ItemGroup>

<ItemGroup>
Expand All @@ -31,6 +32,9 @@
<EmbeddedResource Include="stored-def-missing-input-property.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="def-complex-input-property.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions test/WorkflowCore.TestAssets/def-complex-input-property.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"Id": "FlowWithComplexInputType",
"Version": 1,
"DataType": "WorkflowCore.TestAssets.DataTypes.FlowData, WorkflowCore.TestAssets",
"Steps": [
{
"Id": "AssignTask",
"StepType": "WorkflowCore.TestAssets.Steps.AssignTask, WorkflowCore.TestAssets",
"Inputs": {
"Assignee": {
"id": 1,
"name": "John Doe",
"memberType": 1,
"unitInfo": {
"id": 1,
"name": "IT Department",
"unitType": 1
}
}
},
"Reason": "3"
}
]
}
Loading