public SubmissionResult Create(PostedSubmission model)
        {
            var codeChecker = BaseCodeChecker.GetCodeChecker(model);

            var resultModel = codeChecker.Process();

            var serviceModel = Mapper.Map <SubmissionServiceModel>(resultModel);

            Create(serviceModel);

            return(resultModel);
        }
예제 #2
0
        public void ProcessSubmission_WithUnsupportedLanguage_ThrowsException()
        {
            string expectedExceptionMessage =
                $"Unsupported language";

            PostedSubmission submission = new PostedSubmission()
            {
                ProblemName = "add",
                Language    = "UnsupportedLanguage",
                Code        = @"function add(x, y)
                { 
                   return (x+y);
                }",
                TestCases   = new List <TestCase>()
                {
                    new TestCase()
                    {
                        ExpectedOutput = "3",
                        Parameters     = new List <Parameter>()
                        {
                            new Parameter()
                            {
                                Name  = "x",
                                Value = "1"
                            },
                            new Parameter()
                            {
                                Name  = "y",
                                Value = "2"
                            }
                        }
                    }
                }
            };

            // Assert
            var exception = Assert.Throws <ArgumentException>(() => BaseCodeChecker.GetCodeChecker(submission));

            Assert.Equal(expectedExceptionMessage, exception.Message);
        }
예제 #3
0
        public void ProcessSubmission_WithSupportedLanguage_ReturnsProperChecker()
        {
            PostedSubmission submission = new PostedSubmission()
            {
                ProblemName = "add",
                Language    = "JavaScript",
                Code        = @"function add(x, y)
                { 
                   return (x+y);
                }",
                TestCases   = new List <TestCase>()
                {
                    new TestCase()
                    {
                        ExpectedOutput = "3",
                        Parameters     = new List <Parameter>()
                        {
                            new Parameter()
                            {
                                Name  = "x",
                                Value = "1"
                            },
                            new Parameter()
                            {
                                Name  = "y",
                                Value = "2"
                            }
                        }
                    }
                }
            };

            var checker = BaseCodeChecker.GetCodeChecker(submission);

            Assert.NotNull(checker);
        }