EnrolDelegateOnGroupCourses_add_new_progress_record_sets_CompleteByDate_as_correct_future_date_if_course_CompleteWithinMonths_is_not_zero() { // Given const int completeWithinMonths = 3; var groupCourse = GroupTestHelper.GetDefaultGroupCourse(completeWithinMonths: completeWithinMonths); var expectedFutureDate = testDate.AddMonths(3); SetupEnrolProcessFakes( GenericNewProgressId, GenericRelatedTutorialId, groupCourse ); // When groupsService.EnrolDelegateOnGroupCourses( reusableDelegateDetails, reusableMyAccountDetailsData, 8 ); // Then using (new AssertionScope()) { DelegateProgressRecordMustNotHaveBeenUpdated(); A.CallTo( () => progressDataService.CreateNewDelegateProgress( reusableDelegateDetails.Id, reusableGroupCourse.CustomisationId, reusableGroupCourse.CurrentVersion, testDate, 3, null, expectedFutureDate, A <int> ._ ) ).MustHaveHappened(); A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId)) .MustHaveHappened(); } }
EnrolDelegateOnGroupCourses_add_new_progress_record_uses_course_supervisor_id_if_course_supervisor_is_not_null() { // Given const int supervisorId = 14; var groupCourse = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: supervisorId); SetupEnrolProcessFakes( GenericNewProgressId, GenericRelatedTutorialId ); SetUpAddDelegateEnrolProcessFakes(groupCourse); // When groupsService.EnrolDelegateOnGroupCourses( reusableDelegateDetails, reusableMyAccountDetailsData, 8 ); // Then using (new AssertionScope()) { DelegateProgressRecordMustNotHaveBeenUpdated(); A.CallTo( () => progressDataService.CreateNewDelegateProgress( reusableDelegateDetails.Id, reusableGroupCourse.CustomisationId, reusableGroupCourse.CurrentVersion, testDate, 3, null, testDate.AddMonths(12), supervisorId ) ).MustHaveHappened(); A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId)) .MustHaveHappened(); } }
public void GroupCourseViewModel_populates_expected_values() { // Given var expectedDateTime = new DateTime(2018, 11, 02, 10, 53, 38, 920); var groupCourse = GroupTestHelper.GetDefaultGroupCourse(addedToGroup: expectedDateTime); // When var result = new GroupCourseViewModel(groupCourse); // Then using (new AssertionScope()) { result.GroupCustomisationId.Should().Be(1); result.Name.Should().BeEquivalentTo(groupCourse.CourseName); result.IsMandatory.Should().Be("Not mandatory"); result.IsAssessed.Should().Be("Not assessed"); result.AddedToGroup.Should().Be("02/11/2018"); result.Supervisor.Should().BeNull(); result.CompleteWithin.Should().Be("12 months"); result.ValidFor.Should().BeNull(); } }
AddCourseToGroup_update_sets_CompleteByDate_as_correct_future_date_if_course_CompleteWithinMonths_is_not_zero() { // Given const int completeWithinMonths = 3; var groupCourse = GroupTestHelper.GetDefaultGroupCourse(completeWithinMonths: completeWithinMonths); var expectedFutureDate = testDate.AddMonths(3); SetupEnrolProcessFakes( GenericNewProgressId, GenericRelatedTutorialId, reusableProgressRecord ); SetUpAddCourseEnrolProcessFakes(groupCourse); // When groupsService.AddCourseToGroup( groupCourse.GroupId, groupCourse.CustomisationId, 8, 1, true, 1, centreId ); // Then using (new AssertionScope()) { NewDelegateProgressRecordMustNotHaveBeenAdded(); A.CallTo( () => progressDataService.UpdateProgressSupervisorAndCompleteByDate( reusableProgressRecord.ProgressId, A <int> ._, expectedFutureDate ) ).MustHaveHappened(); } }
AddCourseToGroup_keeps_existing_supervisor_when_updating_progress() { // Given const int adminId = 4; const int supervisorId = 12; var groupCourse = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: supervisorId); SetupEnrolProcessFakes( GenericNewProgressId, GenericRelatedTutorialId, reusableProgressRecord ); SetUpAddCourseEnrolProcessFakes(groupCourse); // When groupsService.AddCourseToGroup( reusableGroupCourse.GroupId, reusableGroupCourse.CustomisationId, 8, adminId, true, supervisorId, centreId ); // Then using (new AssertionScope()) { NewDelegateProgressRecordMustNotHaveBeenAdded(); A.CallTo( () => progressDataService.UpdateProgressSupervisorAndCompleteByDate( reusableProgressRecord.ProgressId, reusableProgressRecord.SupervisorAdminId, A <DateTime?> ._ ) ).MustHaveHappened(); } }
SynchroniseUserChangesWithGroups_adds_delegate_to_synchronised_new_answer_group_when_group_label_includes_prompt_name() { // Given var centreAnswersData = UserTestHelper.GetDefaultCentreAnswersData(answer1: "new answer"); A.CallTo(() => clockService.UtcNow).Returns(testDate); A.CallTo( () => centreRegistrationPromptsService.GetCentreRegistrationPromptNameAndNumber( reusableDelegateDetails.CentreId, 1 ) ).Returns("Prompt Name"); var synchronisedGroup = GroupTestHelper.GetDefaultGroup( 5, "Prompt Name - new answer", linkedToField: 1, changesToRegistrationDetailsShouldChangeGroupMembership: true ); A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns( new List <Group> { synchronisedGroup } ); // When groupsService.SynchroniseUserChangesWithGroups( reusableDelegateDetails, reusableMyAccountDetailsData, centreAnswersData ); // Then DelegateMustHaveBeenAddedToGroups(new List <int> { synchronisedGroup.GroupId }); }
public void GetGroupCourseForCentre_returns_expected_course() { // Given var expectedDateTime = new DateTime(2019, 11, 15, 13, 53, 26, 510); var expectedGroupCourse = GroupTestHelper.GetDefaultGroupCourse( 25, 103, supervisorAdminId: 1, completeWithinMonths: 0, supervisorFirstName: "Kevin", supervisorLastName: "Whittaker (Developer)", addedToGroup: expectedDateTime ); // When var result = groupsDataService.GetGroupCourseForCentre(25, 101); // Then using (new AssertionScope()) { result.Should().NotBeNull(); result.Should().BeEquivalentTo(expectedGroupCourse); } }
public void GetGroupCoursesForCategory_does_not_filter_by_null_category() { // Given var oneCategoryCourse = GroupTestHelper.GetDefaultGroupCourse(); var otherCategoryCourse = GroupTestHelper.GetDefaultGroupCourse( 2, courseCategoryId: 255 ); A.CallTo(() => groupsDataService.GetGroupCoursesForCentre(1)).Returns( new[] { oneCategoryCourse, otherCategoryCourse, } ); // When var result = groupsService.GetGroupCoursesForCategory(8, 1, null).ToList(); // Then result.Should().Contain(oneCategoryCourse); result.Should().Contain(otherCategoryCourse); }
public void GetGroupCoursesForCategory_filters_courses_by_category() { // Given var correctCategoryCourse = GroupTestHelper.GetDefaultGroupCourse(); var incorrectCategoryCourse = GroupTestHelper.GetDefaultGroupCourse( 2, courseCategoryId: 255 ); A.CallTo(() => groupsDataService.GetGroupCoursesForCentre(1)).Returns( new[] { correctCategoryCourse, incorrectCategoryCourse, } ); // When var result = groupsService.GetGroupCoursesForCategory(8, 1, 1).ToList(); // Then result.Should().Contain(correctCategoryCourse); result.Should().NotContain(incorrectCategoryCourse); }
public void InsertGroupCustomisation_inserts_expected_record() { // Given var expectedDateTime = new DateTime(2019, 11, 15, 13, 53, 26, 510); var expectedGroupCourse = GroupTestHelper.GetDefaultGroupCourse( 25, 103, supervisorAdminId: 1, completeWithinMonths: 0, supervisorFirstName: "Kevin", supervisorLastName: "Whittaker (Developer)", addedToGroup: expectedDateTime ); using var transaction = new TransactionScope(); // When var insertedId = groupsDataService.InsertGroupCustomisation( expectedGroupCourse.GroupId, expectedGroupCourse.CustomisationId, expectedGroupCourse.CompleteWithinMonths, 1, true, expectedGroupCourse.SupervisorAdminId ); var result = groupsDataService.GetGroupCourseIfVisibleToCentre(insertedId, 101); // Then using (new AssertionScope()) { result.Should().NotBeNull(); result.Should().BeEquivalentTo( expectedGroupCourse, options => options.Excluding(gc => gc.GroupCustomisationId).Excluding(gc => gc.AddedToGroup) ); } }
public void SynchroniseUserChangesWithGroups_adds_delegate_to_synchronised_new_answer_group() { // Given var centreAnswersData = UserTestHelper.GetDefaultCentreAnswersData(answer1: "new answer"); A.CallTo(() => clockService.UtcNow).Returns(testDate); var synchronisedGroup = GroupTestHelper.GetDefaultGroup( 5, "new answer", linkedToField: 1, changesToRegistrationDetailsShouldChangeGroupMembership: true ); A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns( new List <Group> { synchronisedGroup } ); // When groupsService.SynchroniseUserChangesWithGroups( reusableDelegateDetails, reusableMyAccountDetailsData, centreAnswersData ); // Then A.CallTo( () => groupsDataService.AddDelegateToGroup( reusableDelegateDetails.Id, synchronisedGroup.GroupId, testDate, 1 ) ).MustHaveHappened(); }