public void TestTest() { // create compiler var compiler = new Compiler { Name = "CPP", Location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CPP8\Compiler\CL.EXE"), Extension = "cpp", Arguments = "/I\"$CompilerDirectory$\" $SourceFilePath$ /link /LIBPATH:\"$CompilerDirectory$\"", CompiledExtension = "exe", IsNeedShortPath = true }; var filePath = Helper.CreateFileForCompilation( CompileServiceLanguageSourceCode.CPPCorrectSourceCode, compiler.Extension); string output, error; var result = compiler.Compile(filePath, out output, out error); if (result) { filePath = Path.ChangeExtension(filePath, compiler.CompiledExtension); Status testingResult; // check file path try { Tester.Test("badFilePath", string.Empty, string.Empty, 1, 1); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } // check correct timelimit try { Tester.Test(filePath, string.Empty, string.Empty, -5, 1); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } // check correct memorylimit try { Tester.Test(filePath, string.Empty, string.Empty, 1, -5); Assert.AreEqual(true, false); } catch (Exception) { Assert.AreEqual(true, true); } // test with correct parameters try { testingResult = Tester.Test(filePath, string.Empty, string.Empty, 10000, 3000); Assert.AreEqual("Accepted", testingResult.TestResult); } catch (Exception) { Assert.AreEqual(true, false); } } }
public void CompileTest() { // create compiler var compiler = new Compiler { Name = "CPP", Location = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Compilers\CPP8\Compiler\CL.EXE"), Extension = "cpp", Arguments = "/I\"$CompilerDirectory$\" $SourceFilePath$ /link /LIBPATH:\"$CompilerDirectory$\"", CompiledExtension = "exe", IsNeedShortPath = true }; var filePath = Helper.CreateFileForCompilation( CompileServiceLanguageSourceCode.CPPCorrectSourceCode, compiler.Extension); string output, error; bool result=true; try { result = compiler.Compile("BadFileName", out output, out error); result = false; } catch (Exception) { Assert.AreEqual(true,result); } result = compiler.Compile(filePath, out output, out error); try { result = compiler.Compile(filePath, out output, out error); } catch (Exception) { result = false; } Assert.AreEqual(true, result); // remove file try { File.Delete(filePath); } catch (Exception) { Assert.AreEqual(true, false); } }