public void StepByStepFirstAndLastCallIsSingle() { var provider = new NodeDefinitionProvider(); provider.Register("FirstCall"); provider.Register("ManyCalls", "FirstCall"); provider.Register("LastCall", "ManyCalls"); provider.SetRoot("LastCall"); var node = provider.GetByName("LastCall"); node.SingleCall = true; node = provider.GetByName("FirstCall"); node.SingleCall = true; List <string> messages = new List <string>(); var nodeRegistry = new NodeRegistry <string>(); nodeRegistry.Register("FirstCall", new BaseNode <string>(new FirstCallDataDriver(messages), provider.GetByName("FirstCall"))); nodeRegistry.Register("ManyCalls", new BaseNode <string>(new ManyCallsDataDriver(messages), provider.GetByName("ManyCalls"))); nodeRegistry.Register("LastCall", new BaseNode <string>(new LastCallDataDriver(messages), provider.GetByName("LastCall"))); var runner = new DataNodeRunner <string>(provider, nodeRegistry); runner.Run(); Assert.AreEqual("FirstCall", messages[0]); Assert.AreEqual("Data0", messages[1]); Assert.AreEqual("LastCall", messages[2]); Assert.AreEqual("Data1", messages[3]); Assert.AreEqual("Data2", messages[4]); }
private void Register(string name, IDataDriver <SourceContext> dataDriver) { var nodeDefinition = Attach(new NodeDefinition() { Name = name }); _nodeDefinitionProvider.Register(name, nodeDefinition); _nodeRegistry.Register(name, new BaseNode <SourceContext>(dataDriver, _nodeDefinitionProvider.GetByName(name))); }
public void Run() { var provider = new NodeDefinitionProvider("FileWriter"); provider.Register("FileReader", new NodeDefinition() { Name = "FileReader" }); provider.Register("FileWriter", new NodeDefinition() { Name = "FileWriter", DependsOn = new List <string>() { "ErrorWriter" } }); provider.Register("ErrorWriter", new NodeDefinition() { Name = "ErrorWriter", DependsOn = new List <string>() { "FileReader" } }); var input = @"C:\Temp\My\1.txt"; var output = @"C:\Temp\My\2.txt"; var error = @"C:\Temp\My\errors.txt"; using (StreamWriter sw = new StreamWriter(input)) { for (int i = 0; i < 100000; i++) { if (i % 3000 == 0) { sw.WriteLine($"POOP{i}"); } else { sw.WriteLine(i); } } } var nodeRegistry = new NodeRegistry <FileMoverData>(); nodeRegistry.Register("FileReader", new BaseNode <FileMoverData>(new FileReader(input), provider.GetByName("FileReader"))); nodeRegistry.Register("FileWriter", new BaseNode <FileMoverData>(new FileWriter(output), provider.GetByName("FileWriter"))); nodeRegistry.Register("ErrorWriter", new BaseNode <FileMoverData>(new ErrorWriter(error), provider.GetByName("ErrorWriter"))); var runner = new DataNodeRunner <FileMoverData>(provider, nodeRegistry); runner.Run(); runner.Dispose(); }