public void EnrolDelegateOnGroupCourses_update_uses_course_supervisor_id_if_course_supervisor_id_is_not_null()
        {
            // Given
            const int supervisorId = 12;
            var       groupCourse  = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: supervisorId);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId,
                reusableProgressRecord
                );
            SetUpAddDelegateEnrolProcessFakes(groupCourse);

            // When
            groupsService.EnrolDelegateOnGroupCourses(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                8
                );

            // Then
            using (new AssertionScope())
            {
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                A.CallTo(
                    () => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
                        reusableProgressRecord.ProgressId,
                        supervisorId,
                        A <DateTime?> ._
                        )
                    ).MustHaveHappened();
            }
        }
コード例 #2
0
        public void AddCourseToGroup_adds_new_group_customisations_record()
        {
            // Given
            const int adminId = 1;
            const int completeWithinMonths = 8;
            var       groupCourse          = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: adminId);

            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                groupCourse.GroupId,
                groupCourse.CustomisationId,
                completeWithinMonths,
                adminId,
                true,
                adminId,
                centreId
                );

            // Then
            A.CallTo(
                () => groupsDataService.InsertGroupCustomisation(
                    groupCourse.GroupId,
                    groupCourse.CustomisationId,
                    completeWithinMonths,
                    adminId,
                    true,
                    adminId
                    )
                ).MustHaveHappenedOnceExactly();
        }
        EnrolDelegateOnGroupCourses_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
                );
            SetUpAddDelegateEnrolProcessFakes(groupCourse);

            // When
            groupsService.EnrolDelegateOnGroupCourses(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                8
                );

            // Then
            using (new AssertionScope())
            {
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                A.CallTo(
                    () => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
                        reusableProgressRecord.ProgressId,
                        A <int> ._,
                        expectedFutureDate
                        )
                    ).MustHaveHappened();
            }
        }
コード例 #4
0
        EnrolDelegateOnGroupCourses_update_sets_CompleteByDate_as_null_if_course_CompleteWithinMonths_is_zero()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(completeWithinMonths: 0);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId,
                groupCourse,
                reusableProgressRecord
                );

            // When
            groupsService.EnrolDelegateOnGroupCourses(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                8
                );

            // Then
            using (new AssertionScope())
            {
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                A.CallTo(
                    () => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
                        reusableProgressRecord.ProgressId,
                        A <int> ._,
                        null
                        )
                    ).MustHaveHappened();
            }
        }
        public void EnrolDelegateOnGroupCourses_sends_correct_email_with_additional_CompleteByDate()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                customisationId: 13,
                applicationName: "application",
                customisationName: "customisation",
                completeWithinMonths: 12
                );
            var oldDelegateDetails = UserTestHelper.GetDefaultDelegateUser(
                firstName: "oldFirst",
                lastName: "oldLast",
                emailAddress: "oldEmail"
                );
            var newAccountDetails = UserTestHelper.GetDefaultAccountDetailsData(
                firstName: "newFirst",
                surname: "newLast",
                email: "newEmail"
                );
            var expectedTextBody = genericEmailBodyText + "The date the course should be completed by is 11/12/2022";
            var expectedHtmlBody =
                genericEmailBodyHtml + "<p>The date the course should be completed by is 11/12/2022</p>";

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId
                );
            SetUpAddDelegateEnrolProcessFakes(groupCourse);

            // When
            groupsService.EnrolDelegateOnGroupCourses(
                oldDelegateDetails,
                newAccountDetails,
                8
                );

            // Then
            A.CallTo(
                () => emailService.ScheduleEmail(
                    A <Email> .That.Matches(
                        e =>
                        e.Bcc.IsNullOrEmpty() &&
                        e.Cc.IsNullOrEmpty() &&
                        e.To[0] == newAccountDetails.Email &&
                        e.Subject == "New Learning Portal Course Enrolment" &&
                        e.Body.TextBody == expectedTextBody &&
                        e.Body.HtmlBody == expectedHtmlBody
                        ),
                    A <string> ._,
                    null
                    )
                ).MustHaveHappened();
        }
コード例 #6
0
        public void GroupCourseViewModel_populates_expected_complete_within_value_for_one_month()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                completeWithinMonths: 1
                );

            // When
            var result = new GroupCourseViewModel(groupCourse);

            // Then
            result.CompleteWithin.Should().Be("1 month");
        }
コード例 #7
0
        public void GroupCourseViewModel_populates_expected_values_with_supervisor_name()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                supervisorFirstName: "Test",
                supervisorLastName: "Name"
                );

            // When
            var result = new GroupCourseViewModel(groupCourse);

            // Then
            result.Supervisor.Should().Be("Test Name");
        }
コード例 #8
0
        public void GroupCourseViewModel_populates_expected_values_for_mandatory_assessed_course()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(isMandatory: true, isAssessed: true);

            // When
            var result = new GroupCourseViewModel(groupCourse);

            // Then
            using (new AssertionScope())
            {
                result.IsMandatory.Should().Be("Mandatory");
                result.IsAssessed.Should().Be("Assessed");
            }
        }
コード例 #9
0
        AddCourseToGroup_add_new_progress_record_sets_CompleteByDate_as_correct_future_date_if_course_CompleteWithinMonths_is_not_zero()
        {
            // Given
            const int adminId = 1;
            const int completeWithinMonths = 3;
            var       groupCourse          = GroupTestHelper.GetDefaultGroupCourse(
                completeWithinMonths: completeWithinMonths,
                supervisorAdminId: adminId
                );
            var expectedFutureDate = testDate.AddMonths(3);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId
                );
            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                groupCourse.GroupId,
                groupCourse.CustomisationId,
                completeWithinMonths,
                adminId,
                true,
                adminId,
                centreId
                );

            // Then
            using (new AssertionScope())
            {
                DelegateProgressRecordMustNotHaveBeenUpdated();
                A.CallTo(
                    () => progressDataService.CreateNewDelegateProgress(
                        reusableGroupDelegate.DelegateId,
                        reusableGroupCourse.CustomisationId,
                        reusableGroupCourse.CurrentVersion,
                        testDate,
                        3,
                        adminId,
                        expectedFutureDate,
                        adminId
                        )
                    ).MustHaveHappened();
                A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId))
                .MustHaveHappened();
            }
        }
コード例 #10
0
        public void AddCourseToGroup_sends_correct_email_with_additional_CompleteByDate()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(
                customisationId: 13,
                applicationName: "application",
                customisationName: "customisation",
                completeWithinMonths: 12
                );
            var expectedTextBody = genericEmailBodyText + "The date the course should be completed by is 11/12/2022";
            var expectedHtmlBody =
                genericEmailBodyHtml + "<p>The date the course should be completed by is 11/12/2022</p>";

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId
                );
            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                groupCourse.GroupId,
                groupCourse.CustomisationId,
                8,
                1,
                true,
                1,
                centreId
                );

            // Then
            A.CallTo(
                () => emailService.ScheduleEmail(
                    A <Email> .That.Matches(
                        e =>
                        e.Bcc.IsNullOrEmpty() &&
                        e.Cc.IsNullOrEmpty() &&
                        e.To[0] == reusableGroupDelegate.EmailAddress &&
                        e.Subject == "New Learning Portal Course Enrolment" &&
                        e.Body.TextBody == expectedTextBody &&
                        e.Body.HtmlBody == expectedHtmlBody
                        ),
                    A <string> ._,
                    null
                    )
                ).MustHaveHappened();
        }
コード例 #11
0
        public void AddCourseToGroup_adds_new_progress_record_when_existing_progress_record_is_removed()
        {
            // Given
            const int adminId = 1;
            var       existingProgressRecord = ProgressTestHelper.GetDefaultProgress(removedDate: testDate);
            var       groupCourse            = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: adminId);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId,
                existingProgressRecord
                );
            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                groupCourse.GroupId,
                groupCourse.CustomisationId,
                8,
                adminId,
                true,
                adminId,
                centreId
                );

            // Then
            using (new AssertionScope())
            {
                DelegateProgressRecordMustNotHaveBeenUpdated();
                A.CallTo(
                    () => progressDataService.CreateNewDelegateProgress(
                        reusableGroupDelegate.DelegateId,
                        groupCourse.CustomisationId,
                        groupCourse.CurrentVersion,
                        testDate,
                        3,
                        adminId,
                        A <DateTime?> ._,
                        adminId
                        )
                    ).MustHaveHappened();
                A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId))
                .MustHaveHappened();
            }
        }
コード例 #12
0
        AddCourseToGroup_add_new_progress_record_uses_course_supervisor_id_if_course_supervisor_is_not_null()
        {
            // Given
            const int adminId      = 1;
            const int supervisorId = 14;
            var       groupCourse  = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: supervisorId);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId
                );
            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                reusableGroupCourse.GroupId,
                reusableGroupCourse.CustomisationId,
                8,
                adminId,
                true,
                supervisorId,
                centreId
                );

            // Then
            using (new AssertionScope())
            {
                DelegateProgressRecordMustNotHaveBeenUpdated();
                A.CallTo(
                    () => progressDataService.CreateNewDelegateProgress(
                        reusableGroupDelegate.DelegateId,
                        reusableGroupCourse.CustomisationId,
                        reusableGroupCourse.CurrentVersion,
                        testDate,
                        3,
                        adminId,
                        testDate.AddMonths(12),
                        supervisorId
                        )
                    ).MustHaveHappened();
                A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId))
                .MustHaveHappened();
            }
        }
        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
                );
            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,
                        expectedFutureDate,
                        A <int> ._
                        )
                    ).MustHaveHappened();
                A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId))
                .MustHaveHappened();
            }
        }
コード例 #14
0
        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();
            }
        }
        EnrolDelegateOnGroupCourses_add_new_progress_record_uses_zero_for_supervisor_id_if_course_supervisor_is_null()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(supervisorAdminId: null);

            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,
                        A <DateTime?> ._,
                        0
                        )
                    ).MustHaveHappened();
                A.CallTo(() => progressDataService.CreateNewAspProgress(GenericRelatedTutorialId, GenericNewProgressId))
                .MustHaveHappened();
            }
        }
コード例 #16
0
        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();
            }
        }
コード例 #17
0
        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);
            }
        }
コード例 #18
0
        AddCourseToGroup_update_sets_CompleteByDate_as_null_if_course_CompleteWithinMonths_is_zero()
        {
            // Given
            var groupCourse = GroupTestHelper.GetDefaultGroupCourse(completeWithinMonths: 0);

            SetupEnrolProcessFakes(
                GenericNewProgressId,
                GenericRelatedTutorialId,
                reusableProgressRecord
                );
            SetUpAddCourseEnrolProcessFakes(groupCourse);

            // When
            groupsService.AddCourseToGroup(
                reusableGroupCourse.GroupId,
                reusableGroupCourse.CustomisationId,
                8,
                1,
                true,
                1,
                centreId
                );

            // Then
            using (new AssertionScope())
            {
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                A.CallTo(
                    () => progressDataService.UpdateProgressSupervisorAndCompleteByDate(
                        reusableProgressRecord.ProgressId,
                        A <int> ._,
                        null
                        )
                    ).MustHaveHappened();
            }
        }
コード例 #19
0
        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);
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        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)
                    );
            }
        }