예제 #1
0
        public void CompileServiceTest()
        {
            var compileService = new CompileService();
            var source = CompileServiceLanguageSourceCode.CPPCorrectSourceCode;
            const string Language = "CPP8";
            var input = new string[0];
            var output = new string[0];
            var inputStrings = new[] { "1 2" };
            var outputStrings = new[] { "12" };

            string expected;

            // compile with incorrect language parameter
            try
            {
                expected = compileService.Compile(source, "IncorrectLanguageName", input, output, 100, 100);
                Assert.AreEqual(false, true);
            }
            catch (Exception)
            {
                Assert.AreEqual(true, true);
            }

            try
            {
                expected = compileService.Compile(source, string.Empty, input, output, 100, 100);
                Assert.AreEqual(false, true);
            }
            catch (Exception)
            {
                Assert.AreEqual(true, true);
            }

            // compile with incorrect timelimit parameter
            try
            {
                expected = compileService.Compile(source, Language, inputStrings, outputStrings, -5, 100);
                Assert.AreEqual(false, true);
            }
            catch (Exception)
            {
                Assert.AreEqual(true, true);
            }

            // compile with incorrect memorylimit parameter
            try
            {
                expected = compileService.Compile(source, Language, inputStrings, outputStrings, 100, -5);
                Assert.AreEqual(false, true);
            }
            catch (Exception)
            {
                Assert.AreEqual(true, true);
            }

            // compile with correct parameters
            try
            {
                input = new[] { "2 5", "7 5" };
                output = new[] { "25", "75" };
                expected = compileService.Compile(source, Language, input, output, 1000, 1000);
                Assert.AreEqual(expected, "Accepted");
            }
            catch (Exception)
            {
                Assert.AreEqual(false, true);
            }
        }
예제 #2
0
 public void CompileServiceCheckTest()
 {
   var complieService = new CompileService();
   Assert.AreEqual(complieService.Check(),"Check");
 }