public void ThreeRowsSimple() { var definitionC = new NodeDefinition { Name = "C", DependsOn = new List <string> { "B" } }; var definitionB = new NodeDefinition { Name = "B", DependsOn = new List <string> { "A" } }; var definitionA = new NodeDefinition { Name = "A" }; var counterWrapper = new TestCounterWrapper(); var nodeRegistry = new NodeRegistry <string>(); nodeRegistry.Register("A", new BaseNode <string>(new TestActionProcess(p => { if (p.Number < 3) { p.Item = $"AAA{counterWrapper.Counter++}"; } else { p.Stop(); } }), definitionA)); nodeRegistry.Register("B", new BaseNode <string>(new TestActionProcess(p => { p.Item = p.Item += "BBB"; }), definitionB)); nodeRegistry.Register("C", new BaseNode <string>(new TestActionProcess(p => { p.Item = p.Item += "CCC"; }), definitionC)); var provider = new NodeDefinitionProvider("C"); provider.Register("C", definitionC); provider.Register("B", definitionB); provider.Register("A", definitionA); var runner = new DataNodeRunner <string>(provider, nodeRegistry); var wrapper = new DataItemWrapper <string>(); runner.Step(wrapper); Assert.AreEqual("AAA0BBBCCC", wrapper.Item); runner.Step(wrapper); Assert.AreEqual("AAA1BBBCCC", wrapper.Item); runner.Step(wrapper); Assert.AreEqual("AAA2BBBCCC", wrapper.Item); }
public void ABBCSimpleWhenANodeShouldntBeCalledTwice() { var definitionC = new NodeDefinition { Name = "C", DependsOn = new List <string> { "B", "A" } }; var definitionB = new NodeDefinition { Name = "B", DependsOn = new List <string> { "A" } }; var definitionA = new NodeDefinition { Name = "A" }; var nodeRegistry = new NodeRegistry <string>(); nodeRegistry.Register("A", new BaseNode <string>(new TestActionProcess(p => { p.Item = "AAA"; }), definitionA)); nodeRegistry.Register("B", new BaseNode <string>(new TestActionProcess(p => { p.Item = p.Item += "BBB"; }), definitionB)); nodeRegistry.Register("C", new BaseNode <string>(new TestActionProcess(p => { p.Item = p.Item += "CCC"; }), definitionC)); var provider = new NodeDefinitionProvider("C"); provider.Register("C", definitionC); provider.Register("B", definitionB); provider.Register("A", definitionA); var runner = new DataNodeRunner <string>(provider, nodeRegistry); var wrapper = new DataItemWrapper <string>(); runner.Step(wrapper); Assert.AreEqual("AAABBBCCC", wrapper.Item); }