public void Create_Membership_Failed_Because_User_Rejected() { MembershipCreateResult memberShipCreateResult = new MembershipCreateResult { MembershipUserObject = null, CreateStatus = MembershipCreateStatus.UserRejected }; _memberShipMock.Setup(x => x.CreateUser(It.IsAny<UserInformation>(), true)).Returns(memberShipCreateResult); var accountController = new AccountController(_memberShipMock.Object); var actionResult = accountController.Register(_userInformationView); Assert.That(((ViewResult)actionResult).ViewBag.ErrorMessage, Is.EqualTo("The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator.")); Assert.That(((ViewResult)actionResult).ViewData.Model, Is.EqualTo(_userInformationView)); Assert.That(((ViewResult)actionResult).ViewData["PageTitle"], Is.EqualTo("Register New User")); }
public void Create_Membership_Fails_For_Duplicate_Email() { MembershipCreateResult memberShipCreateResult = new MembershipCreateResult { MembershipUserObject = null, CreateStatus = MembershipCreateStatus.DuplicateEmail }; _memberShipMock.Setup(x => x.CreateUser(It.IsAny<UserInformation>(), true)).Returns(memberShipCreateResult); var accountController = new AccountController(_memberShipMock.Object); var actionResult = accountController.Register(_userInformationView); Assert.That(((ViewResult)actionResult).ViewBag.ErrorMessage, Is.EqualTo("A username for that e-mail address already exists. Please enter a different e-mail address.")); Assert.That(((ViewResult)actionResult).ViewData.Model, Is.EqualTo(_userInformationView)); Assert.That(((ViewResult)actionResult).ViewData["PageTitle"], Is.EqualTo("Register New User")); }
public void Create_Membership_Fails_For_Invalid_Answer() { MembershipCreateResult memberShipCreateResult = new MembershipCreateResult { MembershipUserObject = null, CreateStatus = MembershipCreateStatus.InvalidAnswer }; _memberShipMock.Setup(x => x.CreateUser(It.IsAny<UserInformation>(), true)).Returns(memberShipCreateResult); var accountController = new AccountController(_memberShipMock.Object); var actionResult = accountController.Register(_userInformationView); Assert.That(((ViewResult)actionResult).ViewBag.ErrorMessage, Is.EqualTo("The password retrieval answer provided is invalid. Please check the value and try again.")); Assert.That(((ViewResult)actionResult).ViewData.Model, Is.EqualTo(_userInformationView)); Assert.That(((ViewResult)actionResult).ViewData["PageTitle"], Is.EqualTo("Register New User")); }
public void Successful_Login_After_User_Creation_Redirects_To_Url_If_Specified() { MembershipCreateResult memberShipCreateResult = new MembershipCreateResult { MembershipUserObject = null, CreateStatus = MembershipCreateStatus.Success }; //_userInformationView.ReturnUrl = "/"; _memberShipMock.Setup(x => x.CreateUser(It.IsAny<UserInformation>(), true)).Returns(memberShipCreateResult); _memberShipMock.Setup(x => x.ValidateUser(_userInformationView.UserName, _userInformationView.Password)).Returns(true); var accountController = new AccountController(_memberShipMock.Object); var actionResult = accountController.Register(_userInformationView); Assert.That(actionResult, Is.TypeOf<RedirectResult>()); Assert.That(((RedirectResult)actionResult).Url, Is.EqualTo("/")); }
public void Invalid_Credentials_Causes_Login_To_Fail_After_User_Creation() { MembershipCreateResult memberShipCreateResult = new MembershipCreateResult { MembershipUserObject = null, CreateStatus = MembershipCreateStatus.Success }; _memberShipMock.Setup(x => x.CreateUser(It.IsAny<UserInformation>(), true)).Returns(memberShipCreateResult); _memberShipMock.Setup(x => x.ValidateUser(_userInformationView.UserName, _userInformationView.Password)).Returns(false); var accountController = new AccountController(_memberShipMock.Object); var actionResult = accountController.Register(_userInformationView); Assert.That(((ViewResult)actionResult).ViewBag.ErrorMessage, Is.EqualTo("Login failed! Please make sure you are using the correct user name and password.")); Assert.That(((ViewResult)actionResult).ViewData.Model, Is.EqualTo(_userInformationView)); Assert.That(((ViewResult)actionResult).ViewData["PageTitle"], Is.EqualTo("Register New User")); }