public void TestPasswordAndConfirmPasswordDoNotMatch() { MockStoreContexts mocks = new MockStoreContexts(); Change_PasswordModel cpm = new Change_PasswordModel(mocks.UserManager.Object, mocks.SignInManager.Object) { Password = "******", ConfirmPassword = "******" }; var result = cpm.OnPostAsync().Result; Assert.IsType <PageResult>(result); }
public void TestPasswordAndConfirmPasswordDoMatchButInvalidModel() { MockStoreContexts mocks = new MockStoreContexts(); Change_PasswordModel cpm = new Change_PasswordModel(mocks.UserManager.Object, mocks.SignInManager.Object) { Password = "******", ConfirmPassword = "******" }; MockValidation.CheckValidation(cpm); var result = cpm.OnPostAsync().Result; Assert.IsType <PageResult>(result); }
public void TestPasswordMatchingAndValidModelStateButNoUserIsFound() { MockStoreContexts mocks = new MockStoreContexts(); Change_PasswordModel cpm = new Change_PasswordModel(mocks.UserManager.Object, mocks.SignInManager.Object) { Name = "*****@*****.**", Password = "******", ConfirmPassword = "******" }; mocks.UserManager.Setup(x => x.FindByNameAsync(It.IsAny <string>())) .ReturnsAsync((ApplicationUser)null); MockValidation.CheckValidation(cpm); var result = cpm.OnPostAsync().Result; Assert.IsType <PageResult>(result); }
public void TestPasswordMatchingAndValidModelStateAndUserButFailedToUpdate() { MockStoreContexts mocks = new MockStoreContexts(); Change_PasswordModel cpm = new Change_PasswordModel(mocks.UserManager.Object, mocks.SignInManager.Object) { Name = "*****@*****.**", Password = "******", ConfirmPassword = "******" }; mocks.UserManager.Setup(x => x.FindByNameAsync(It.IsAny <string>())) .ReturnsAsync(new ApplicationUser { PasswordHash = "abcdefg" }); mocks.UserManager.Setup(x => x.UpdateAsync(It.IsAny <ApplicationUser>())) .ReturnsAsync(IdentityResult.Failed()); MockValidation.CheckValidation(cpm); var result = cpm.OnPostAsync().Result; Assert.IsType <PageResult>(result); }
public void TestPasswordMatchingAndValidModelStateAndUserAndUpdates() { MockStoreContexts mocks = new MockStoreContexts(); Change_PasswordModel cpm = new Change_PasswordModel(mocks.UserManager.Object, mocks.SignInManager.Object) { Name = "*****@*****.**", Password = "******", ConfirmPassword = "******" }; mocks.UserManager.Setup(x => x.FindByNameAsync(It.IsAny <string>())) .ReturnsAsync(new ApplicationUser { PasswordHash = "abcdefg" }); mocks.UserManager.Setup(x => x.UpdateAsync(It.IsAny <ApplicationUser>())) .ReturnsAsync(IdentityResult.Success); MockValidation.CheckValidation(cpm); var result = cpm.OnPostAsync().Result; RedirectToPageResult check = (RedirectToPageResult)result; Assert.Equal("/Dashboard", check.PageName); }