public void SubstitutedCommand() { Pipeline.RegisterCommandFactory("Add.IsAwesome", (command) => { // The first included script references a second script if (command.NormalizedCommandName.ToLower() == "Add.IsAwesome".ToLower()) { return(PipelineCommandParser.ParseCommandString("Text.Append -suffix:IsAwesome")); } else { return(new List <PipelineCommand>()); } }); var p = new Pipeline(); p.AddCommand("Text.Append -suffix:Foo"); p.AddCommand("Add.IsAwesome"); p.AddCommand("Text.Append -suffix:Bar"); var result = p.Execute(); Assert.AreEqual("FooIsAwesomeBar", result); }
public void Logging() { Pipeline.RegisterCommandFactory("*", (command) => { return(PipelineCommandParser.ParseCommandString("Text.Prepend -prefix:doesntmatter")); }); var p = new Pipeline(); p.AddCommand("Text.Append -suffx:doesntmatter"); p.Execute(); Assert.AreEqual(p.LogEntries.First().CommandFactorySource, "Text.Append -suffx:doesntmatter"); }
public void SimpleFactory() { Pipeline.RegisterCommandFactory("Core.Include", (command) => { return(PipelineCommandParser.ParseCommandString("Text.Append -suffix:Bar")); }); var p = new Pipeline(); p.AddCommand("Text.Append -suffix:Foo"); p.AddCommand("Include"); p.AddCommand("Text.Append -suffix:Baz"); var result = p.Execute(); Assert.AreEqual("FooBarBaz", result); }
public void NestedInclude() { Pipeline.RegisterCommandFactory("Core.Include", (command) => { // The first incl;uded script references a second script if (command.GetArgument("key") == "first") { return(PipelineCommandParser.ParseCommandString("Text.Append -suffix:Bar1").Concat(PipelineCommandParser.ParseCommandString("Core.Include -key:second"))); } // This is the second script return(PipelineCommandParser.ParseCommandString("Text.Append -suffix:Bar2")); }); var p = new Pipeline(); p.AddCommand("Text.Append -suffix:Foo"); p.AddCommand("Include -key:first"); p.AddCommand("Text.Append -suffix:Baz"); var result = p.Execute(); Assert.AreEqual("FooBar1Bar2Baz", result); }