static void Main(string[] args) { PyTester pyTester = new PyTester(Judge.URI); while (true) { if (pyTester.Test()) { Console.WriteLine("All tests passed"); } else { Console.WriteLine("Some test failed"); } if (!ConsoleUtils.getBooleanKeyAnswer("Do you want to rerun tests with the same module? [y/n]: ")) { if (ConsoleUtils.getBooleanKeyAnswer("Change source directory? [y/n]: ")) { pyTester.completeTestSetup(); } else { pyTester.updateProblemID(); } } } }
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); }