Esempio n. 1
0
 public ActionResult DeleteUser(string userName)
 {
     try
     {
         userAdminService.DeleteUser(userName);
         TempData["Message"] = string.Format("<p class='note'>User '{0}' successfully deleted.<p>", userName);
         return(RedirectToAction("Index"));
     }
     catch (Exception ex)
     {
         Elmah.ErrorLog.GetDefault(null).Log(new Elmah.Error(ex));
         TempData["Message"] = string.Format("<p class='warning'>There was a problem deleting user '{0}'. {1}<p>", userName, ex.Message);
         return(RedirectToAction("Index"));
     }
 }
Esempio n. 2
0
        public void DeleteUser_when_no_exception_occurs_returns_true()
        {
            //arrange
            var mock = new Mock <MembershipProvider>();

            mock.Setup(x => x.DeleteUser("username", true));
            _provider = mock.Object;
            var mut = new UserAdminService(_provider);
            //act
            var result = mut.DeleteUser("username");

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