public ActionResult ChangeName(ChangeNameViewModel model) { User userExist = accountRepository.GetUserByEmail(model.Email); if (userExist != null && model.NewName != null) { accountRepository.ChangeName(model.Email, model.NewName); this.Success(string.Format("Name changed to {0}", model.NewName)); } else { this.Error(string.Format("Name not changed")); } User retmodel = accountRepository.GetUserByEmail(model.Email); return View("PersonalPage",retmodel); }
public void User_Can_Not_Change_Name() { // Arrange ChangeNameViewModel model = new ChangeNameViewModel { Email = "*****@*****.**", }; // Act ActionResult res = accountController.ChangeName(model); // Assert mock.Verify(m => m.ChangeName(model.Email, model.NewName), Times.Never()); Assert.IsInstanceOf(typeof(ViewResult), res); }