public void ThreeStepWithMultilineAsciiArt()
{
List<string> results1 = new List<string>();
List<string> results2 = new List<string>();
StartPoint<int> s = Helpers.GetStartpointCounter(1, 50);
TaskNode<int, string, string> splitter =
new TaskNode<int, string, string>(
(int i, IWritableQueue<string> o1, IWritableQueue<string> o2) =>
{
if (i % 3 == 0 || i % 4 == 0 || i % 5 == 0)
{
// divisible by 3, 4 or 5, go to stream 1
o1.Send(i.ToString(CultureInfo.InvariantCulture));
}else{
// if not, send i and i+1 to stream 2
o2.Send(i.ToString());
o2.Send((i + 1).ToString(CultureInfo.InvariantCulture));
}
}
);
EndPoint<string> end1 = Helpers.GetEndpoint(results1);
EndPoint<string> end2 = Helpers.GetEndpoint(results2);
Flow flow = Flow.FromAsciiArt(@"
s--+
|
V
t0->n
1
|
+---->m
",
new Dictionary<char, TaskNode>()
{
{'s', s},
{'t', splitter},
{'n', end1},
{'m', end2}
}
);
flow.Start();
flow.RunToCompletion();
Assert.AreEqual(29, results1.Count);
Assert.AreEqual("50", results1[28]);
Assert.AreEqual(42, results2.Count);
}