Example #1
0
        public void GetSolutionTest()
        {
            const long   submitId   = 1;
            const long   userId     = 2;
            const string sourceCode = "qwe";

            var submitResult = new SubmitResult(new ProblemSubmit
            {
                FileName   = "main.cpp",
                Id         = submitId,
                LanguageId = 4,
                ProblemId  = 6,
                SourceCode = sourceCode,
                UserId     = userId,
            })
            {
                Id = submitId
            };

            const string taskName = "task";

            var task = new TaskName
            {
                IsOpened = true,
                Name     = taskName
            };

            _submitResultRepository.Stub(o => o.Get(submitId)).Return(submitResult);
            _taskRepository.Stub(o => o.Get(6)).Return(task);

            var result = _service.GetSolution(submitId, userId);

            Assert.NotNull(result);
            Assert.That(result.SourceCode, Is.EqualTo(sourceCode));
            Assert.That(result.ProblemName, Is.EqualTo(taskName));
        }
Example #2
0
        public ActionResult Solution(long submitResultId)
        {
            var userId = User.Identity.GetUserId <long>();

            try
            {
                var model = _submitSolutionService.GetSolution(submitResultId, userId);
                if (model == null)
                {
                    return(HttpNotFound());
                }

                return(View(model));
            }
            catch (AuthenticationException)
            {
                throw new HttpException(401, "AuthenticationException");
            }
        }