Skip to content

Commit 1fea082

Browse files
author
Daniel Gerlag
committed
end step
1 parent 4d45f3e commit 1fea082

File tree

3 files changed

+58
-58
lines changed

3 files changed

+58
-58
lines changed

src/WorkflowCore/Interface/IStepBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public interface IStepBuilder<TData, TStepBody>
8585
/// Ends the workflow and marks it as complete
8686
/// </summary>
8787
/// <returns></returns>
88-
//IStepBuilder<TData, TStepBody> EndWorkflow();
88+
IStepBuilder<TData, TStepBody> EndWorkflow();
8989

9090
IParentStepBuilder<TData, Foreach> ForEach(Expression<Func<TData, IEnumerable>> collection);
9191

src/WorkflowCore/Services/StepBuilder.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -141,13 +141,13 @@ private WorkflowStep IterateParents(int id, string name)
141141
return null;
142142
}
143143

144-
//public IStepBuilder<TData, TStepBody> EndWorkflow()
145-
//{
146-
// EndStep newStep = new EndStep();
147-
// WorkflowBuilder.AddStep(newStep);
148-
// Step.Outcomes.Add(new StepOutcome() { NextStep = newStep.Id });
149-
// return this;
150-
//}
144+
public IStepBuilder<TData, TStepBody> EndWorkflow()
145+
{
146+
EndStep newStep = new EndStep();
147+
WorkflowBuilder.AddStep(newStep);
148+
Step.Outcomes.Add(new StepOutcome() { NextStep = newStep.Id });
149+
return this;
150+
}
151151

152152
public IParentStepBuilder<TData, Foreach> ForEach(Expression<Func<TData, IEnumerable>> collection)
153153
{

test/WorkflowCore.IntegrationTests/Scenarios/EndStepScenario.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,57 +8,57 @@
88

99
namespace WorkflowCore.IntegrationTests.Scenarios
1010
{
11-
//public class EndStepScenario : BaseScenario<EndStepScenario.ScenarioWorkflow, Object>
12-
//{
13-
// internal static int StartStepCounter = 0;
14-
// internal static int MidStepCounter = 0;
15-
// internal static int EndStepCounter = 0;
11+
public class EndStepScenario : BaseScenario<EndStepScenario.ScenarioWorkflow, Object>
12+
{
13+
internal static int StartStepCounter = 0;
14+
internal static int MidStepCounter = 0;
15+
internal static int EndStepCounter = 0;
1616

17-
// public class ScenarioWorkflow : IWorkflow
18-
// {
19-
// public string Id => "EndStepScenario";
20-
// public int Version => 1;
21-
// public void Build(IWorkflowBuilder<Object> builder)
22-
// {
23-
// builder
24-
// .StartWith(context =>
25-
// {
26-
// StartStepCounter++;
27-
// return ExecutionResult.Next();
28-
// })
29-
// .While(x => true)
30-
// .Do(x => x
31-
// .StartWith(context =>
32-
// {
33-
// MidStepCounter++;
34-
// return ExecutionResult.Next();
35-
// }))
36-
// .EndWorkflow()
37-
// .Then(context =>
38-
// {
39-
// EndStepCounter++;
40-
// return ExecutionResult.Next();
41-
// });
42-
// }
43-
// }
17+
public class ScenarioWorkflow : IWorkflow
18+
{
19+
public string Id => "EndStepScenario";
20+
public int Version => 1;
21+
public void Build(IWorkflowBuilder<Object> builder)
22+
{
23+
builder
24+
.StartWith(context =>
25+
{
26+
StartStepCounter++;
27+
return ExecutionResult.Next();
28+
})
29+
.While(x => true)
30+
.Do(x => x
31+
.StartWith(context =>
32+
{
33+
MidStepCounter++;
34+
return ExecutionResult.Next();
35+
})
36+
.EndWorkflow())
37+
.Then(context =>
38+
{
39+
EndStepCounter++;
40+
return ExecutionResult.Next();
41+
});
42+
}
43+
}
4444

45-
// [Fact]
46-
// public void Scenario()
47-
// {
48-
// var workflowId = Host.StartWorkflow("EndStepScenario").Result;
49-
// var instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result;
50-
// int counter = 0;
51-
// while ((instance.Status == WorkflowStatus.Runnable) && (counter < 300))
52-
// {
53-
// System.Threading.Thread.Sleep(100);
54-
// counter++;
55-
// instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result;
56-
// }
45+
[Fact]
46+
public void Scenario()
47+
{
48+
var workflowId = Host.StartWorkflow("EndStepScenario").Result;
49+
var instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result;
50+
int counter = 0;
51+
while ((instance.Status == WorkflowStatus.Runnable) && (counter < 300))
52+
{
53+
System.Threading.Thread.Sleep(100);
54+
counter++;
55+
instance = PersistenceProvider.GetWorkflowInstance(workflowId).Result;
56+
}
5757

58-
// instance.Status.Should().Be(WorkflowStatus.Complete);
59-
// StartStepCounter.Should().Be(1);
60-
// MidStepCounter.Should().Be(1);
61-
// EndStepCounter.Should().Be(0);
62-
// }
63-
//}
58+
instance.Status.Should().Be(WorkflowStatus.Complete);
59+
StartStepCounter.Should().Be(1);
60+
MidStepCounter.Should().Be(1);
61+
EndStepCounter.Should().Be(0);
62+
}
63+
}
6464
}

0 commit comments

Comments
 (0)