Exemple #1
0
        public void ChangePasswordGet()
        {
            SettingsController controller = new SettingsController(_userRepoMock.Object, _loginUser);
            ViewResult         result     = controller.ChangePassword();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.ViewName == "");
            Assert.IsNull(result.Model);
        }
Exemple #2
0
        public void ChangePasswordPost_Failed()
        {
            ChangePassword model = new ChangePassword();

            _userRepoMock.Setup(m => m.ChangePassword(model, _loginUser.UserId)).Returns(false);
            SettingsController controller = new SettingsController(_userRepoMock.Object, _loginUser);
            ActionResult       result     = controller.ChangePassword(model);

            Assert.IsNotNull(result);
            Assert.IsTrue(result is ViewResult);
            Assert.IsTrue((result as ViewResult).ViewName == "");
            Assert.IsNull((result as ViewResult).Model);
            Assert.IsTrue(controller.TempData.ContainsKey("notification"));
            Assert.IsTrue(controller.TempData["notification"] is Notification);
            Assert.IsTrue((controller.TempData["notification"] as Notification).Type == NotificationType.Error);
            Assert.IsTrue(!String.IsNullOrEmpty((controller.TempData["notification"] as Notification).Text));
        }
Exemple #3
0
        public void ChangePasswordPost()
        {
            ChangePassword model = new ChangePassword();;

            _userRepoMock.Setup(m => m.ChangePassword(model, _loginUser.UserId)).Returns(true);
            SettingsController controller = new SettingsController(_userRepoMock.Object, _loginUser);
            ActionResult       result     = controller.ChangePassword(model);

            Assert.IsNotNull(result);
            Assert.IsTrue(result is RedirectToRouteResult);
            Assert.IsTrue((result as RedirectToRouteResult).RouteValues.ContainsKey("action"));
            Assert.IsTrue((result as RedirectToRouteResult).RouteValues.ContainsKey("controller"));
            Assert.IsTrue((result as RedirectToRouteResult).RouteValues["action"].ToString() == "Index");
            Assert.IsTrue((result as RedirectToRouteResult).RouteValues["controller"].ToString() == "Home");

            Assert.IsTrue(controller.TempData.ContainsKey("notification"));
            Assert.IsTrue(controller.TempData["notification"] is Notification);
            Assert.IsTrue((controller.TempData["notification"] as Notification).Type == NotificationType.Success);
            Assert.IsTrue(!String.IsNullOrEmpty((controller.TempData["notification"] as Notification).Text));
        }