public IResult Execute(string codeFilePath) { var fileName = Path.GetFileNameWithoutExtension(codeFilePath); var testerFileName = FileUtilities.GetTesterFileName(fileName); var testerFilePath = FileUtilities.GetTesterFilePath(testerFileName); var compilerResultsForCode = CodeExecutionUtilities.Compile(codeFilePath); var compilerResultsForTester = CodeExecutionUtilities.Compile(testerFilePath); if (compilerResultsForCode.Errors.HasErrors) { return(this.HandleCompilationErrors(compilerResultsForCode)); } var solutionInstance = compilerResultsForCode.CompiledAssembly.CreateInstance("Problem1") as ISolution; return(RunTesterForTheSolution(compilerResultsForTester, solutionInstance, codeFilePath)); }
private IResult RunTesterForTheSolution(CompilerResults compilerResultsForTester, ISolution solutionInstance, string codeFilePath) { var result = new Result(); bool isSuccessful; try { isSuccessful = (bool)CodeExecutionUtilities.Run( compilerResultsForTester, "MasterServer.TesterFiles.Problem1Tester", "Test", new[] { solutionInstance as Object, codeFilePath } ); } catch (Exception e) { result.RanSuccessfully = false; result.ErrorMessage = e.InnerException.ToString(); return(result); } return(isSuccessful ? this.PrepareResultForSuccessfulRun() : PrepareResultForUnsuccessfulRun(codeFilePath)); }