public IRequestGenerator Execute(GeneratorArgs args, string pluginDirectory) { var loader = new RequestGeneratorPluginLoader(pluginDirectory); IRequestGenerator requestGenerator = loader.Load().First(g => g.Name.Equals(args.Name, StringComparison.InvariantCultureIgnoreCase)); // add options if (args.Arguments != null && args.Arguments.Count > 0) { for (int i = 0; i < args.Arguments.Count; i++) { string argument = null; string value = null; if (args.Arguments[i].StartsWith("#")) { argument = args.Arguments[i].TrimStart('#'); value = args.Arguments[i + 1]; } int index = -1; if (!string.IsNullOrWhiteSpace(argument) && (index = requestGenerator.Options.FindLastIndex(o => o.Description.Key.Equals(argument))) > -1) { requestGenerator.Options[index].Value = value; } } } return(requestGenerator); }
private static IEnumerable<string> GeneratorNames() { var loader = new RequestGeneratorPluginLoader(Controller.PluginDir()); foreach (var generator in loader.Load()) { yield return $"\"{generator.Name}\""; } }
public void List(ListArgs args) { var loader = new RequestGeneratorPluginLoader(PluginDir()); foreach (var generator in loader.Load()) { CliResultViews.DrawGenerator(generator); } }
public async Task LoadPluginTest() { var loader = new RequestGeneratorPluginLoader(Path.GetDirectoryName(Assembly.GetAssembly(typeof(RequestGeneratorPluginLoaderTests)).Location)); var generators = loader.Load(); Assert.True(generators != null); Assert.True(generators.Count() > 0); var generator = generators.First(); generator.Options[0].Value = "42"; // number of requests for plugin to return Assert.Equal("42", generator.Options[0].Value); var results = generator.Run(); Assert.Equal(42, results.Count()); }