Update tests
This commit is contained in:
parent
9c321a5fe0
commit
be913c7aa0
|
|
@ -26,10 +26,17 @@ public class Tests
|
|||
var workflow = new WorkflowDefinitionBuilder().BuildWorkflow<BreakWhileBlockForkWorkflow>();
|
||||
|
||||
// Start workflow.
|
||||
await _workflowRunner.RunAsync(workflow);
|
||||
var result1 = await _workflowRunner.RunAsync(workflow);
|
||||
|
||||
// Resume one of the branches.
|
||||
var bookmark = result1.Bookmarks.FirstOrDefault(x => x.ActivityId == "Branch 1");
|
||||
var result2 = await _workflowRunner.RunAsync(workflow, result1.WorkflowState, bookmark);
|
||||
|
||||
// Assert that all bookmarks have been cleared.
|
||||
Assert.Empty(result2.Bookmarks);
|
||||
|
||||
// Verify expected output.
|
||||
var lines = _capturingTextWriter.Lines.ToList();
|
||||
Assert.Equal(new[] { "Current value: 0", "Branch 1", "Blocking Branch 2" }, lines);
|
||||
Assert.Equal(new[] { "Branch 1", "Branch 2", "Branch 1 - Resumed" }, lines);
|
||||
}
|
||||
}
|
||||
|
|
@ -13,27 +13,34 @@ public class BreakWhileBlockForkWorkflow : IWorkflow
|
|||
var currentValue = new Variable<int?>(0);
|
||||
|
||||
workflow.WithVariable(currentValue);
|
||||
workflow.WithRoot(new While(context => currentValue.Get(context) < 3)
|
||||
workflow.WithRoot(new While(() => true)
|
||||
{
|
||||
Body =
|
||||
new Sequence
|
||||
{
|
||||
Activities =
|
||||
{
|
||||
new WriteLine(context => $"Current value: {currentValue.Get<int>(context)}"),
|
||||
new SetVariable<int?>(currentValue, context => currentValue.Get(context) + 1),
|
||||
new Fork
|
||||
{
|
||||
JoinMode = JoinMode.WaitAll,
|
||||
Branches =
|
||||
{
|
||||
new WriteLine("Branch 1"),
|
||||
new Sequence{
|
||||
Activities =
|
||||
{
|
||||
new WriteLine("Branch 1"),
|
||||
new Event("Branch 1") { Id = "Branch 1" },
|
||||
new WriteLine("Branch 1 - Resumed"),
|
||||
new Break()
|
||||
}
|
||||
},
|
||||
new Sequence
|
||||
{
|
||||
Activities =
|
||||
{
|
||||
new WriteLine("Blocking Branch 2"),
|
||||
new Event("Some event") { Id = "SomeEvent" },
|
||||
new WriteLine("Resuming Branch 2"),
|
||||
new WriteLine("Branch 2"),
|
||||
new Event("Branch 2") { Id = "Branch 2" },
|
||||
new WriteLine("Branch 2 - Resumed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue