示例#1
0
        public void HidePassedTestsForAcceptedTest()
        {
            var submit = ProblemSubmit.Create();

            submit.ProblemId = 1;
            submit.UserId    = 1;
            var submits = new[] { new SubmitResult(submit)
                                  {
                                      Status = SubmitStatus.Accepted, PassedTests = 10
                                  } };

            _submitResultRepository.Stub(
                o => o.GetSubmits(Arg <ISpecification <SubmitResult> > .Is.Anything, Arg <int> .Is.Anything, Arg <int> .Is.Anything))
            .Return(submits);

            _taskRepository.Stub(o => o.GetTasks(Arg <long[]> .Is.Anything)).Return(new[] { new TaskName {
                                                                                                Id = 1, Name = "A+B"
                                                                                            } });

            _userRepository.Stub(o => o.GetUsers(Arg <long[]> .Is.Anything)).Return(new[] { new User {
                                                                                                Id = 1
                                                                                            } });

            var model = _service.GetSubmitQueue(1, 1, 1);

            Assert.That(model.Submits.Select(o => o.PassedTests), Is.All.Null);
        }
示例#2
0
        public void SolvedProblemsTest()
        {
            const long userId       = 5;
            const long solvedTaskId = 1;

            var tasks = new[]
            {
                new TaskName {
                    Id = solvedTaskId, Name = "A"
                },
                new TaskName {
                    Id = 2, Name = "B"
                },
                new TaskName {
                    Id = 3, Name = "C"
                }
            };

            _taskRepository.Stub(o => o.GetTasks(OpenedTasksSpecification.Instance, 1, 2)).Return(tasks);
            _taskRepository.Stub(o => o.Count(true)).Return(tasks.Length);

            _submitResultRepository.Stub(o => o.GetSolvedProblems(Arg <ISpecification <SubmitResult> > .Is.Anything)).Return(new[] { solvedTaskId });

            var model = _service.GetProblemsList(1, 2, userId, true);

            CollectionAssert.AreEqual(tasks.Select(o => new { o.Id, o.Name, Solved = o.Id == solvedTaskId }), model.Problems.Select(o => new { o.Id, o.Name, o.Solved }));
        }
示例#3
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));
        }