Esempio n. 1
0
        public void SynchroniseUserChangesWithGroups_does_nothing_if_no_groups_need_synchronising()
        {
            // Given
            var delegateDetails      = UserTestHelper.GetDefaultDelegateUser();
            var centreAnswersData    = UserTestHelper.GetDefaultCentreAnswersData();
            var nonSynchronisedGroup = GroupTestHelper.GetDefaultGroup(
                5,
                "new answer",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: false
                );

            A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns(
                new List <Group> {
                nonSynchronisedGroup
            }
                );

            // When
            groupsService.SynchroniseUserChangesWithGroups(
                delegateDetails,
                reusableMyAccountDetailsData,
                centreAnswersData
                );

            // Then
            using (new AssertionScope())
            {
                DelegateMustNotHaveBeenRemovedFromAGroup();
                DelegateMustNotHaveBeenAddedToAGroup();
                DelegateProgressRecordMustNotHaveBeenUpdated();
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                NoEnrolmentEmailsMustHaveBeenSent();
            }
        }
Esempio n. 2
0
        SynchroniseUserChangesWithGroups_does_nothing_if_synchronised_groups_for_changed_fields_have_different_values()
        {
            // Given
            var centreAnswersData = UserTestHelper.GetDefaultCentreAnswersData(answer1: "new answer");
            var synchronisedGroup = GroupTestHelper.GetDefaultGroup(
                5,
                "differentValue",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: true
                );

            A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns(
                new List <Group> {
                synchronisedGroup
            }
                );

            // When
            groupsService.SynchroniseUserChangesWithGroups(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                centreAnswersData
                );

            // Then
            using (new AssertionScope())
            {
                DelegateMustNotHaveBeenRemovedFromAGroup();
                DelegateMustNotHaveBeenAddedToAGroup();
                DelegateProgressRecordMustNotHaveBeenUpdated();
                NewDelegateProgressRecordMustNotHaveBeenAdded();
                NoEnrolmentEmailsMustHaveBeenSent();
            }
        }
        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
            DelegateMustHaveBeenAddedToGroups(new List <int> {
                synchronisedGroup.GroupId
            });
        }
Esempio n. 4
0
        public void GetGroupAtCentreById_returns_expected_group()
        {
            // Given
            var expectedGroup = GroupTestHelper.GetDefaultGroup();

            // When
            var result = groupsDataService.GetGroupAtCentreById(34, 101);

            //Then
            result.Should().BeEquivalentTo(expectedGroup);
        }
Esempio n. 5
0
        SynchroniseUserChangesWithGroups_removes_delegate_from_synchronised_old_answer_group_when_group_label_includes_prompt_name()
        {
            // Given
            var        centreAnswersData       = UserTestHelper.GetDefaultCentreAnswersData(answer1: "new answer");
            const bool removeStartedEnrolments = false;

            A.CallTo(() => clockService.UtcNow).Returns(testDate);
            A.CallTo(
                () => centreCustomPromptsService.GetPromptNameForCentreAndPromptNumber(
                    reusableDelegateDetails.CentreId,
                    1
                    )
                ).Returns("Prompt Name");
            var synchronisedGroup = GroupTestHelper.GetDefaultGroup(
                5,
                "Prompt Name - old 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.DeleteGroupDelegatesRecordForDelegate(
                    synchronisedGroup.GroupId,
                    reusableDelegateDetails.Id
                    )
                ).MustHaveHappened();
            A.CallTo(
                () => groupsDataService.RemoveRelatedProgressRecordsForGroup(
                    synchronisedGroup.GroupId,
                    reusableDelegateDetails.Id,
                    removeStartedEnrolments,
                    testDate
                    )
                ).MustHaveHappened();
        }
Esempio n. 6
0
        public void GetGroupAtCentreById_returns_expected_group()
        {
            // Given
            const int groupId  = 1;
            const int centreId = 1;
            var       group    = GroupTestHelper.GetDefaultGroup();

            A.CallTo(() => groupsDataService.GetGroupAtCentreById(groupId, centreId)).Returns(group);

            // When
            var result = groupsService.GetGroupAtCentreById(groupId, centreId);

            // Then
            result.Should().BeEquivalentTo(group);
        }
        SynchroniseUserChangesWithGroups_removes_delegate_from_all_synchronised_old_answer_groups_if_multiple_exist()
        {
            // 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 synchronisedGroup1 = GroupTestHelper.GetDefaultGroup(
                5,
                "old answer",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: true
                );
            var synchronisedGroup2 = GroupTestHelper.GetDefaultGroup(
                6,
                "Prompt Name - old answer",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: true
                );

            A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns(
                new List <Group> {
                synchronisedGroup1, synchronisedGroup2
            }
                );

            // When
            groupsService.SynchroniseUserChangesWithGroups(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                centreAnswersData
                );

            // Then
            DelegateMustHaveBeenRemovedFromGroups(
                new List <int> {
                synchronisedGroup1.GroupId, synchronisedGroup2.GroupId
            }
                );
        }
        SynchroniseUserChangesWithGroups_adds_delegate_to_synchronised_new_answer_groups_when_group_labels_differ_in_casing()
        {
            // 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 synchronisedGroup1 = GroupTestHelper.GetDefaultGroup(
                5,
                "NEW ANSWER",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: true
                );
            var synchronisedGroup2 = GroupTestHelper.GetDefaultGroup(
                6,
                "PROMPT NAME - NEW ANSWER",
                linkedToField: 1,
                changesToRegistrationDetailsShouldChangeGroupMembership: true
                );

            A.CallTo(() => groupsDataService.GetGroupsForCentre(A <int> ._)).Returns(
                new List <Group> {
                synchronisedGroup1, synchronisedGroup2
            }
                );

            // When
            groupsService.SynchroniseUserChangesWithGroups(
                reusableDelegateDetails,
                reusableMyAccountDetailsData,
                centreAnswersData
                );

            // Then
            DelegateMustHaveBeenAddedToGroups(new List <int> {
                synchronisedGroup1.GroupId, synchronisedGroup2.GroupId
            });
        }
Esempio n. 9
0
        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(
                () => centreCustomPromptsService.GetPromptNameForCentreAndPromptNumber(
                    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
            A.CallTo(
                () => groupsDataService.AddDelegateToGroup(
                    reusableDelegateDetails.Id,
                    synchronisedGroup.GroupId,
                    testDate,
                    1
                    )
                ).MustHaveHappened();
        }