예제 #1
0
        public void ChangePassword()
        {
            IList <UserAccount> accounts = new List <UserAccount>();

            NMock.Actions.InvokeAction saveUser = new NMock.Actions.InvokeAction(new Action(() => accounts.Add(userAccount)));
            accountAdministrationDaoMock.Expects.Any.MethodWith(x => x.SaveOrUpdateUser(userAccount)).Will(saveUser);
            accountAdministrationServiceMock.Expects.Any.MethodWith(x => x.SaveOrUpdateUser(userAccount)).Will(saveUser);

            userInformationServiceMock.Expects.Any.MethodWith(x => x.GetUserAccountById(userAccount.Id)).WillReturn(userAccount);
            userInformationDaoMock.Expects.Any.MethodWith(x => x.GetUserAccountById(userAccount.Id)).WillReturn(userAccount);

            authorizationServiceMock.Expects.Any.MethodWith(x => x.EncryptPassword(oldPassword)).WillReturn(oldPassword);
            authorizationServiceMock.Expects.Any.MethodWith(x => x.EncryptPassword(newPassword)).WillReturn(newPassword);

            managementService.ChangePassword(userAccountId, oldPassword, newPassword);
            UserAccount userAccount2 = userInformationService.GetUserAccountById(userAccountId);

            Assert.AreEqual(userAccount2.Password, newPassword);
        }