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); }
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)); }
public void FirstPageTest() { const int pageSize = 100; const int page = 1; var tasks = new[] { new TaskName { Id = 1, Name = "A" }, new TaskName { Id = 2, Name = "B" } }; _taskRepository.Stub(o => o.GetTasks(OpenedTasksSpecification.Instance, page, pageSize)).Return(tasks); _taskRepository.Stub(o => o.Count(true)).Return(tasks.Length); var model = _service.GetProblemsList(page, pageSize, null, true); Assert.That(model.ProblemsCount, Is.EqualTo(2)); Assert.That(model.Pagination.PageSize, Is.EqualTo(pageSize)); Assert.That(model.Pagination.CurrentPage, Is.EqualTo(page)); Assert.That(model.Pagination.TotalPages, Is.EqualTo(1)); CollectionAssert.AreEqual(tasks.Select(o => new { o.Id, o.Name }), model.Problems.Select(o => new { o.Id, o.Name })); }