public void GetCandidateExercisesResults_CandidateId_ReturnsOrderedByScoreDescending() { var result1 = new CandidateTestResult() { Id = 1, CreatorId = _candidateId, Score = 3 }; var result2 = new CandidateTestResult() { Id = 2, CreatorId = _candidateId, Score = 0 }; var result3 = new CandidateTaskResult() { Id = 3, CreatorId = _candidateId, IsCompleted = true, Score = 9 }; var result4 = new CandidateTaskResult() { Id = 4, CreatorId = _candidateId, IsCompleted = true, Score = 4 }; _testResults.Add(result1); _testResults.Add(result2); _taskResults.Add(result3); _taskResults.Add(result4); var results = _service.GetCandidateExercisesResults(_candidateId).ToArray(); Assert.That(results, Is.Ordered.Descending.By("Score")); }
public void GetItems_TwoItems_ReturnTwoItems() { // Arrange. var candidateTask = new DemoLab.Models.ExerciseManagement.CandidateTask { Id = 1 }; var candidateTest = new DemoLab.Models.ExerciseManagement.CandidateTest { Id = 2 }; var exercises = new DemoLab.Models.ExerciseManagement.CandidateExercise[] { candidateTask, candidateTest }; _exercisePoolMock.Setup(pool => pool.GetActiveExerciseSet()).Returns(exercises); var candidateTaskResult = new CandidateTaskResult { CreatorId = Guid.Empty, CandidateExercise = new DemoLab.Data.Access.ExerciseManagement.CandidateTask { Id = 1 } }; var candidateTestResult = new CandidateTestResult { CreatorId = Guid.Empty, CandidateExercise = new DemoLab.Data.Access.ExerciseManagement.CandidateExercise { Id = 2 } }; var fakeTaskSet = new FakeEntitySet <CandidateTaskResult>(new List <CandidateTaskResult> { candidateTaskResult }); var fakeTestSet = new FakeEntitySet <CandidateTestResult>(new List <CandidateTestResult> { candidateTestResult }); _exerciseContextMock.SetupGet(t => t.CandidateTaskResults).Returns(fakeTaskSet); _exerciseContextMock.SetupGet(t => t.CandidateTestResults).Returns(fakeTestSet); _service = new ExerciseService( _exerciseContextMock.Object, _exercisePoolMock.Object, _testAssemblyContextMock.Object); // Act. var result = _service.GetCandidateExerciseList(applicationUserId: Guid.NewGuid()); // Assert. Assert.AreEqual(2, result.Count()); }
public void GetCandidateExercisesResults_CandidateId_ReturnsAllCompletedTasksResults() { var result1 = new CandidateTaskResult() { Id = 1, CreatorId = _candidateId, IsCompleted = true }; var result2 = new CandidateTaskResult() { Id = 2, CreatorId = _candidateId, IsCompleted = true }; var result3 = new CandidateTaskResult() { Id = 3, CreatorId = _candidateId, IsCompleted = false }; _taskResults.Add(result1); _taskResults.Add(result2); _taskResults.Add(result3); var results = _service.GetCandidateExercisesResults(_candidateId).ToArray(); CollectionAssert.AreEquivalent(new[] { result1.Id, result2.Id }, results.Select(r => r.Id)); }