private string GetArgString(string process, BaseJobTaskConfig taskConfig, Dictionary <string, string> additionalConfigs) { var dict = new Dictionary <string, object> { { "process", process }, { "config", taskConfig }, { "additional", additionalConfigs } }; return(JsonConvert.SerializeObject(dict)); }
public async void GenericExecution_Success() { var workingLocation = Path.Combine(AppContext.BaseDirectory, "working"); var config = new BaseJobTaskConfig { WorkingLocation = workingLocation }; if (Directory.Exists(workingLocation)) { Directory.Delete(workingLocation, true); } var additionalConfig = new Dictionary <string, string>(); bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); var sb = new StringBuilder(); sb.AppendLine("echo test-text > test.txt"); if (isWindows) { sb.AppendLine("copy test.txt test2.txt"); } else { sb.AppendLine("cp test.txt test2.txt"); } additionalConfig["CommandScriptPath"] = sb.ToString(); var provider = new Program(new string[] { GetArgString("main", config, additionalConfig) }); var result = await provider.GenericExecution(); Assert.True(File.Exists(Path.Combine(workingLocation, "test.txt"))); Assert.True(File.Exists(Path.Combine(workingLocation, "test2.txt"))); Assert.Equal("The commands has been run successfully", result.successMessage); }