public void ItValidatesPasswords() { var validator = new DefaultPasswordValidator(); Assert.IsTrue(validator.IsValid("LetMeIn98")); Assert.IsTrue(validator.IsValid("LetMeIn98@&*")); Assert.IsTrue(validator.IsValid("Let Me In 98")); Assert.IsFalse(validator.IsValid("Let98")); Assert.IsFalse(validator.IsValid(" LetMeIn98 ")); Assert.IsFalse(validator.IsValid("LetMeIn98\t")); Assert.IsFalse(validator.IsValid("LetMeInForReal")); Assert.IsFalse(validator.IsValid("letmeinforreal")); }
public void VerifyPassword_EmptyPasswordWithValidatorFunction_CorrectResult() { string password = ""; var repo = new MockRepository(MockBehavior.Default); var reopositoryMock = repo.Create <IPasswordCheckerRepository>(); reopositoryMock.Setup(lw => lw.Create(password)); var validator = new DefaultPasswordValidator(); var validationMock = repo.Create <IValidator <string> >(); validationMock.Setup(lm => lm.IsValid(password)).Returns(validator.IsValid(password)); var service = new PasswordCheckerService(reopositoryMock.Object, validationMock.Object); service.VerifyPassword(password); repo.Verify(); }