public async Task TestCreateUserAndDuplicatesClaims() { using (var fixture = new WebHostFixture()) { var userManager = fixture.GetUserManager(); var roleManager = fixture.GetRoleManager(); await InitializeIdentity.SeedPermissions <PermissionsTest>(roleManager).SeedAsync(); await InitializeIdentity.SeedPermissions <PermissionsTest>(roleManager).SeedAsync(); var defaultRole = roleManager.Roles.ToList()[0]; var claims = await roleManager.GetClaimsAsync(defaultRole); var user = new ApplicationUser { Email = "*****@*****.**", UserName = "******" }; // IN SEQUENCE var created = await userManager.CreateAsync(user, "Aa@123456"); // var result = await userManager.AddClaimsAsync(user, claims); // var userClaims = await userManager.GetClaimsAsync(user); Assert.True(result.Succeeded); Assert.Equal(2, claims.Count()); Assert.Equal(2, userClaims.Count()); } }
public async Task TestInitializeIdentitySeedRoles() { using (var fixture = new WebHostFixture()) { var roleManager = fixture.GetRoleManager(); await InitializeIdentity.SeedPermissions <PermissionsTest>(roleManager).SeedAsync(); var roles = roleManager.Roles.ToList(); var claims = await roleManager.GetClaimsAsync(roles[0]); Assert.True(roles.Count == 1); Assert.True(claims.Count == 2); Assert.Equal("1", claims[0].Value); Assert.Equal("2", claims[1].Value); } }
public PermissionsSeederTests() { var webHost = new WebHostFixture(); _roleManager = webHost.GetRoleManager(); }