public void ChangeUserPassword_Returns_ResetResult_With_Failure_When_Entered_User_Does_Not_Exist() { BannerID testBannerID = BannerID.CreateBannerID("A00000001"); string testSamAccountName = "testSamAccount"; string newPassword = "******"; User testEnteredUser = new User(testBannerID, testSamAccountName, "test, user one"); var mockRepo = new Mock <IActiveDirectoryRepository>(); mockRepo.Setup(repo => repo.FindUserByBannerID(testEnteredUser.BannerID)).Returns((User)null); UserAccountService userAccountService = new UserAccountService(mockRepo.Object); ResetResult result = userAccountService.ChangeUserPassword(testEnteredUser, newPassword); Assert.IsTrue(result.HasErrorMessage); Assert.AreEqual(testEnteredUser, result.User); }
public void ChangeUserPassword_Returns_ResetResult_With_No_Failures() { BannerID testBannerID = BannerID.CreateBannerID("A00000000"); string testSamAccountName = "testSamAccount"; string newPassword = "******"; User testUser = new User(testBannerID, testSamAccountName, "test, user one"); var mockRepo = new Mock <IActiveDirectoryRepository>(); mockRepo.Setup(repo => repo.FindUserByBannerID(testUser.BannerID)).Returns(testUser); mockRepo.Setup(repo => repo.ChangeUserPassword(testUser, newPassword)).Returns(true); mockRepo.Setup(repo => repo.ChangeUserResetAttribute(testUser)).Returns(true); UserAccountService userAccountService = new UserAccountService(mockRepo.Object); ResetResult result = userAccountService.ChangeUserPassword(testUser, newPassword); Assert.IsFalse(result.HasErrorMessage); Assert.AreEqual(testUser, result.User); }