//Since RunExe returns the results string, we run it and right after add it to the result list. public void RunSubmittedProgram() { if (exeExists) { if (TestCases.testCases.Count != 0) { numberOfOverallResults = 0; submittedProgramOutputs.Clear(); //Reset the output results upon a new Run so compiledProgramOutputs.Clear(); //we can add fresh results. foreach (SingleTestCase tc in TestCases.testCases) { if (File.Exists(exePath) && Submissions.checkExe) //If there's a submitted .exe and it needs to be checked. { string outputResults = CodeChecker.RunEXE(exePath, tc.input); submittedProgramOutputs.Add(new OutputResult(outputResults)); } if (File.Exists(compiledExePath) && Submissions.checkCode) //If there's just the compiled .exe and only it needs to be checked. { string outputResults = CodeChecker.RunEXE(compiledExePath, tc.input); compiledProgramOutputs.Add(new OutputResult(outputResults)); } } numberOfOverallResults = Math.Max(submittedProgramOutputs.Count, compiledProgramOutputs.Count); } if (File.Exists(exePath) && File.Exists(compiledExePath)) { possibleCheating = !CompareBothLists(); //If the 2 lists are different, there might be a possible cheating. Check manually. } } }
public void RunEXE_ReturnsOutput() { //Arrange var filePath = @"..\..\..\Assets\Test Required FIles\CodeCheckerTest\Source.exe"; var input = "2 3"; //Act var results = CodeChecker.RunEXE(filePath, input); Assert.IsNotNull(results); }