public async Task ValidateThrowsWithNullTest() { // Setup var validator = new InvalidPhraseValidator <TestUser>(new [] { "phrase" }); // Act // Assert await Assert.ThrowsAsync <ArgumentNullException>("password", () => validator.ValidateAsync(null, null, null)); await Assert.ThrowsAsync <ArgumentNullException>("manager", () => validator.ValidateAsync(null, null, "foo")); }
public async Task SuccessIfNotContained(string password, params string[] phrases) { var manager = MockHelpers.TestUserManager <TestUser>(); var validator = new InvalidPhraseValidator <TestUser>(phrases); var user = new TestUser(); IdentityResultAssert.IsSuccess(await validator.ValidateAsync(manager, user, password)); }
public async Task FailsIfContained(string password, params string[] phrases) { var manager = MockHelpers.TestUserManager <TestUser>(); var validator = new InvalidPhraseValidator <TestUser>(phrases); var user = new TestUser(); var error = $"You cannot use '{password}' as your password"; IdentityResultAssert.IsFailure(await validator.ValidateAsync(manager, user, password), error); }
public async Task ValidateDoesNotThrowWithNullUserTest() { // Setup var validator = new InvalidPhraseValidator <TestUser>(new [] { "phrase" }); var manager = MockHelpers.TestUserManager <TestUser>(); var password = "******"; // Act // Assert IdentityResultAssert.IsSuccess(await validator.ValidateAsync(manager, null, password)); }