示例#1
0
        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"));
        }
示例#2
0
        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));
        }
示例#3
0
        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);
        }
示例#4
0
        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));
        }