Skip to content

Commit

Permalink
Additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ElemarJR committed Jul 27, 2018
1 parent e901bed commit 02c318b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/TheFlow/CoreConcepts/Token.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public Token AllocateChild()
throw new InvalidOperationException("AllocationChild is not allowed after releasing.");
}

var allocateChild = new Token(
var allocateChild = new Token(
Id,
Guid.NewGuid(),
ExecutionPoint
Expand Down
41 changes: 40 additions & 1 deletion test/TheFlow.Tests/Functional/RunningTwoPathsInParallel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void ActivitiesRanInTheRightSequence()
}

[Fact]
public void ReturnTwoTokensWhenThereIsAnEventHandlerInOneOfThePaths()
public void ReturnTwoTokensWhenThereAreEventHandlersInBothPaths()
{
var model = ProcessModel.Create()
.AddEventCatcher("start")
Expand All @@ -70,5 +70,44 @@ public void ReturnTwoTokensWhenThereIsAnEventHandlerInOneOfThePaths()
var result = manager.HandleEvent(null);
result.FirstOrDefault().AffectedTokens.Count().Should().Be(2);
}

[Fact]
public void ReturnOneTokenWhenThereIsAnEventHandlerInOneOfThePaths()
{
var model = ProcessModel.Create()
.AddEventCatcher("start")
.AddActivity("msgBefore", () => { })
.AddParallelGateway("split")
.AddSequenceFlow("start", "msgBefore", "split")
.AddActivity("msgLeft", () => { })
.AddEventCatcher("evtLeft")
.AddActivity("msgRight", () => { })
.AddParallelGateway("join")
.AddSequenceFlow("split", "msgLeft", "evtLeft", "join")
.AddSequenceFlow("split", "msgRight", "join")
.AddActivity("msgAfter", () => { })
.AddEventThrower("end")
.AddSequenceFlow("join", "msgAfter", "end");

var models = new InMemoryProcessModelsStore(model);
var instances = new InMemoryProcessInstancesStore();

var manager = new ProcessManager(models, instances);

var results = manager.HandleEvent(null).ToArray();
results.Length.Should().Be(1);

var result = results[0];
var affectedTokens = result.AffectedTokens.ToArray();

affectedTokens.Length.Should().Be(1);

result = manager
.HandleEvent(result.ProcessInstanceId, affectedTokens[0], null);
//.AffectedTokens.

var instance = manager.InstancesStore.GetById(result.ProcessInstanceId);
instance.IsDone.Should().BeTrue();
}
}
}

0 comments on commit 02c318b

Please sign in to comment.