Example #1
0
 public void ChangePassword_when_oldpassword_is_null_throw_exception()
 {
     //arrange
     var mut = new UserAdminService(_provider);
     //act
     var result = mut.ChangePassword("username", null, "newpassword");
     //assert
     //cleanup
 }
Example #2
0
 public void ChangePassword_when_newpassword_is_emptystring_throw_exception()
 {
     //arrange
     var mut = new UserAdminService(_provider);
     //act
     var result = mut.ChangePassword("username", "oldpassword", "");
     //assert
     //cleanup
 }
 public ActionResult Index(ChangePasswordModel model)
 {
     if (ModelState.IsValid)
     {
         var result = userAdminService.ChangePassword(model.UserName, model.OldPassword, model.NewPassword);
         ViewBag.Message  = result ? "<p class='note'>Password updated successfully.</p>" : "<p class='warning'>Password not changed.  Current password not correct.</p>";
         ViewBag.UserName = model.UserName;
         return(View("ChangePassword", model));
     }
     ViewBag.Message  = "<p class='warning'>Unable to change password. Check the passwords match.</p>";
     ViewBag.UserName = model.UserName;
     return(View("ChangePassword", model));
 }
Example #4
0
        public void ChangePassword_when_no_exception_returns_change_password_status_result()
        {
            //arrange
            var mock = new Mock <MembershipProvider>();

            mock.Setup(x => x.GetUser("username", true)).Returns(new FakeMembershipUser());
            _provider = mock.Object;
            var mut = new UserAdminService(_provider);
            //act
            var result = mut.ChangePassword("username", "oldpassword", "newpassword");

            //assert
            Assert.AreEqual(true, result);
            //cleanup
            _provider = null;
        }
Example #5
0
        public void ChangePassword_when_get_user_or_change_password_throws_membershippasswordexception_exception_returns_false()
        {
            //arrange
            var mock = new Mock <MembershipProvider>();

            mock.Setup(x => x.GetUser("username", true)).Throws(new MembershipPasswordException());
            _provider = mock.Object;
            var mut = new UserAdminService(_provider);
            //act
            var result = mut.ChangePassword("username", "oldpassword", "newpassword");

            //assert
            Assert.AreEqual(false, result);
            //cleanup
            _provider = null;
        }