コード例 #1
0
        public void UpdateUserAccountDetailsForAllVerifiedUsers_with_null_delegate_only_updates_admin()
        {
            // Given
            var    adminUser          = UserTestHelper.GetDefaultAdminUser();
            string password           = "******";
            var    firstName          = "TestFirstName";
            var    lastName           = "TestLastName";
            var    email              = "*****@*****.**";
            var    accountDetailsData =
                new MyAccountDetailsData(adminUser.Id, null, password, firstName, lastName, email, null);

            A.CallTo(() => userDataService.GetAdminUserById(adminUser.Id)).Returns(adminUser);
            A.CallTo(() => userDataService.GetAdminUserByEmailAddress(adminUser.EmailAddress !)).Returns(adminUser);
            A.CallTo(() => userDataService.GetDelegateUsersByEmailAddress(adminUser.EmailAddress !))
            .Returns(new List <DelegateUser>());
            A.CallTo(() => userVerificationService.VerifyUsers(password, A <AdminUser?> ._, A <List <DelegateUser> > ._))
            .Returns(new UserAccountSet(adminUser, new List <DelegateUser>()));
            A.CallTo(() => userDataService.UpdateAdminUser(A <string> ._, A <string> ._, A <string> ._, null, A <int> ._))
            .DoesNothing();

            // When
            userService.UpdateUserAccountDetailsForAllVerifiedUsers(accountDetailsData);

            // Then
            A.CallTo(() => userDataService.UpdateAdminUser(A <string> ._, A <string> ._, A <string> ._, null, A <int> ._))
            .MustHaveHappened();
            A.CallTo(() => userDataService.UpdateDelegateUsers(A <string> ._, A <string> ._, A <string> ._, null, A <int[]> ._))
            .MustNotHaveHappened();
            A.CallTo(() => userDataService.GetDelegateUserById(A <int> ._)).MustNotHaveHappened();
        }
コード例 #2
0
        public void UpdateUserAccountDetailsForAllVerifiedUsers_with_incorrect_password_doesnt_update()
        {
            // Given
            var    adminUser          = UserTestHelper.GetDefaultAdminUser();
            var    delegateUser       = UserTestHelper.GetDefaultDelegateUser();
            string signedInEmail      = "*****@*****.**";
            string password           = "******";
            var    firstName          = "TestFirstName";
            var    lastName           = "TestLastName";
            var    email              = "*****@*****.**";
            var    accountDetailsData =
                new MyAccountDetailsData(adminUser.Id, delegateUser.Id, password, firstName, lastName, email, null);
            var centreAnswersData = new CentreAnswersData(2, 1, null, null, null, null, null, null);

            A.CallTo(() => userDataService.GetAdminUserById(adminUser.Id)).Returns(adminUser);
            A.CallTo(() => userDataService.GetDelegateUserById(delegateUser.Id)).Returns(delegateUser);
            A.CallTo(() => userDataService.GetAdminUserByEmailAddress(signedInEmail)).Returns(null);
            A.CallTo(() => userDataService.GetDelegateUsersByEmailAddress(signedInEmail))
            .Returns(new List <DelegateUser>());
            A.CallTo(() => userVerificationService.VerifyUsers(password, A <AdminUser?> ._, A <List <DelegateUser> > ._))
            .Returns(new UserAccountSet());
            A.CallTo(
                () => groupsService.SynchroniseUserChangesWithGroups(
                    A <DelegateUser> ._,
                    A <MyAccountDetailsData> ._,
                    A <CentreAnswersData> ._
                    )
                ).DoesNothing();

            // When
            userService.UpdateUserAccountDetailsForAllVerifiedUsers(accountDetailsData, centreAnswersData);

            // Then
            A.CallTo(() => userDataService.UpdateDelegateUsers(A <string> ._, A <string> ._, A <string> ._, null, A <int[]> ._))
            .MustNotHaveHappened();
            A.CallTo(() => userDataService.UpdateAdminUser(A <string> ._, A <string> ._, A <string> ._, null, A <int> ._))
            .MustNotHaveHappened();
            A.CallTo(
                () => userDataService.UpdateDelegateUserCentrePrompts(
                    A <int> ._,
                    A <int> ._,
                    A <string?> ._,
                    A <string?> ._,
                    A <string?> ._,
                    A <string?> ._,
                    A <string?> ._,
                    A <string?> ._
                    )
                )
            .MustNotHaveHappened();
            A.CallTo(
                () => groupsService.SynchroniseUserChangesWithGroups(
                    A <DelegateUser> ._,
                    A <MyAccountDetailsData> ._,
                    A <CentreAnswersData> ._
                    )
                ).MustNotHaveHappened();
        }