public void CanDelegateAccessSelfAssessment_returns_true_with_no_completed_or_removed_assessments() { // Given var candidateAssessments = Builder <CandidateAssessment> .CreateListOfSize(5).All() .With(ca => ca.CompletedDate = null) .With(ca => ca.RemovedDate = null) .Build().ToList(); A.CallTo(() => selfAssessmentDataService.GetCandidateAssessments(A <int> ._, A <int> ._)) .Returns(candidateAssessments); // When var result = selfAssessmentService.CanDelegateAccessSelfAssessment(1, 1); // Then result.Should().BeTrue(); }
public void AddResourceToActionPlan_calls_expected_insert_data_service_methods() { // Given const int learningResourceReferenceId = 1; const int delegateId = 2; const int selfAssessmentId = 3; const int candidateAssessmentId = 4; const string resourceName = "Activity"; const string resourceLink = "www.test.com"; const int learningLogId = 4; const int learningHubResourceId = 6; var addedDate = new DateTime(2021, 11, 1); A.CallTo(() => clockService.UtcNow).Returns(addedDate); A.CallTo( () => learningResourceReferenceDataService.GetLearningHubResourceReferenceById( learningResourceReferenceId ) ).Returns(learningHubResourceId); var resource = new ResourceReferenceWithResourceDetails { Title = resourceName, Link = resourceLink }; A.CallTo(() => learningHubResourceService.GetResourceByReferenceId(learningHubResourceId)) .Returns((resource, true)); var resourceCompetencies = new[] { 1, 2, 3, 4, 5, 6, 7, 8 }; A.CallTo( () => competencyLearningResourcesDataService.GetCompetencyIdsLinkedToResource( learningResourceReferenceId ) ).Returns(resourceCompetencies); var assessmentCompetencies = new[] { 2, 3, 5, 6, 8, 9, 10 }; A.CallTo(() => selfAssessmentDataService.GetCompetencyIdsForSelfAssessment(selfAssessmentId)) .Returns(assessmentCompetencies); A.CallTo(() => selfAssessmentDataService.GetCandidateAssessments(delegateId, selfAssessmentId)) .Returns( new[] { Builder <CandidateAssessment> .CreateNew().With(ca => ca.Id = candidateAssessmentId).Build() } ); A.CallTo( () => learningLogItemsDataService.InsertLearningLogItem( A <int> ._, A <DateTime> ._, A <string> ._, A <string> ._, A <int> ._ ) ).Returns(learningLogId); var expectedMatchingCompetencies = new[] { 2, 3, 5, 6, 8 }; // When actionPlanService.AddResourceToActionPlan(learningResourceReferenceId, delegateId, selfAssessmentId); // Then A.CallTo( () => learningLogItemsDataService.InsertLearningLogItem( delegateId, addedDate, resourceName, resourceLink, learningResourceReferenceId ) ).MustHaveHappenedOnceExactly(); A.CallTo( () => learningLogItemsDataService.InsertCandidateAssessmentLearningLogItem( candidateAssessmentId, learningLogId ) ).MustHaveHappenedOnceExactly(); foreach (var competencyId in expectedMatchingCompetencies) { A.CallTo( () => learningLogItemsDataService.InsertLearningLogItemCompetencies( learningLogId, competencyId, addedDate ) ).MustHaveHappenedOnceExactly(); } A.CallTo( () => learningLogItemsDataService.InsertLearningLogItemCompetencies(learningLogId, A <int> ._, addedDate) ).MustHaveHappened(5, Times.Exactly); }
public bool CanDelegateAccessSelfAssessment(int delegateId, int selfAssessmentId) { var candidateAssessments = selfAssessmentDataService.GetCandidateAssessments(delegateId, selfAssessmentId); return(candidateAssessments.Any(ca => ca.CompletedDate == null && ca.RemovedDate == null)); }