// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading.Tasks; using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.DependencyInjection.Fallback; using Xunit; namespace Microsoft.AspNet.Identity.Test { public class RoleValidatorTest { [Fact] public async Task ValidateThrowsWithNull() { // Setup var validator = new RoleValidator(); var manager = new RoleManager(new NoopRoleStore(), validator); // Act // Assert await Assert.ThrowsAsync("manager", async () => await validator.ValidateAsync(null, null)); await Assert.ThrowsAsync("role", async () => await validator.ValidateAsync(manager, null)); } [Theory] [InlineData(null)] [InlineData("")] public async Task ValidateFailsWithTooShortRoleName(string input) { // Setup var validator = new RoleValidator(); var manager = new RoleManager(new NoopRoleStore(), validator); var user = new TestRole {Name = input}; // Act var result = await validator.ValidateAsync(manager, user); // Assert IdentityResultAssert.IsFailure(result, "Name cannot be null or empty."); } } }