private bool defineProblemID() { int problemID = int.MinValue; string module = null; string testModule = null; string moduleName = null; string testModuleNamePath = null; bool moduleFileExist = true; bool testModuleFileExist = true; bool chooseCreateFile = false; void checkFiles() { moduleFileExist = File.Exists(module); testModuleFileExist = File.Exists(testModule); } void showInexistentFileDialog(string moduleName) { ConsoleUtils.writeLineCleared("{0} does not exist. Do you want to create it?", moduleName); chooseCreateFile = ConsoleUtils.getBooleanKeyAnswer("Press Y if you going to create it or N if you want to change the problem ID. [y/n]: "); if (chooseCreateFile) { ConsoleUtils.writeLineCleared("Press any key after creating {0}: ", moduleName); Console.ReadKey(); checkFiles(); } } do { if (!moduleFileExist) { showInexistentFileDialog(moduleName); } else if (!testModuleFileExist) { showInexistentFileDialog(testModuleNamePath); } if (!chooseCreateFile) { problemID = ConsoleUtils.getIntegerInput("Insert the problem ID: "); moduleName = problemID + this.fileExtension; module = this.sourceDir + moduleName; testModuleNamePath = this.testRelativePath + problemID + this.testExtension + this.fileExtension; testModule = this.sourceDir + testModuleNamePath; checkFiles(); } } while (!moduleFileExist || !testModuleFileExist); if (problemID == int.MinValue || module is null || testModule is null) { return(false); } this.problemID = problemID; this.module = module; this.testModule = testModule; return(true); }
public bool Test() { int testAmount = ConsoleUtils.getIntegerInput("Insert how many tests you want to run: ", true); return(Test(testAmount)); }