Merge pull request #18270 from abpframework/auto-merge/rel-7-4/2297

Merge branch rel-8.0 with rel-7.4
pull/18356/head
maliming 1 year ago committed by GitHub
commit c3cc43080a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -82,7 +82,7 @@ public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
return await CreateAsync(user);
}
public async override Task<IdentityResult> DeleteAsync(IdentityUser user)
{
user.Claims.Clear();

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.DependencyInjection;
using Shouldly;
using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Xunit;
namespace Volo.Abp.Identity;
@ -13,11 +14,17 @@ public abstract class IdentityRoleRepository_Tests<TStartupModule> : AbpIdentity
{
protected IIdentityRoleRepository RoleRepository { get; }
protected ILookupNormalizer LookupNormalizer { get; }
protected IdentityUserManager UserManager { get; }
protected IdentityTestData TestData { get; }
protected IUnitOfWorkManager UnitOfWorkManager { get; }
protected IdentityRoleRepository_Tests()
{
RoleRepository = ServiceProvider.GetRequiredService<IIdentityRoleRepository>();
LookupNormalizer = ServiceProvider.GetRequiredService<ILookupNormalizer>();
UserManager = ServiceProvider.GetRequiredService<IdentityUserManager>();
TestData = ServiceProvider.GetRequiredService<IdentityTestData>();
UnitOfWorkManager = ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
}
[Fact]
@ -77,6 +84,19 @@ public abstract class IdentityRoleRepository_Tests<TStartupModule> : AbpIdentity
roles.ShouldContain(r => r.Role.Name == "moderator" && r.UserCount == 1);
roles.ShouldContain(r => r.Role.Name == "supporter" && r.UserCount == 2);
roles.ShouldContain(r => r.Role.Name == "manager" && r.UserCount == 1);
using (var uow = UnitOfWorkManager.Begin())
{
var userBob = await UserManager.FindByIdAsync(TestData.UserBobId.ToString());
await UserManager.DeleteAsync(userBob!);
await uow.CompleteAsync();
}
roles = await RoleRepository.GetListWithUserCountAsync();
roles.Count.ShouldBe(5);
roles.ShouldContain(r => r.Role.Name == "manager" && r.UserCount == 0);
roles.ShouldContain(r => r.Role.Name == "sale" && r.UserCount == 0);
}
}

Loading…
Cancel
Save