Browse Source

add create role with org details unit test

pull/5292/head
向洪林 6 years ago
parent
commit
62277ec59e
  1. 31
      modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

31
modules/identity/test/Volo.Abp.Identity.Application.Tests/Volo/Abp/Identity/IdentityRoleAppService_Tests.cs

@ -11,11 +11,14 @@ namespace Volo.Abp.Identity
{
private readonly IIdentityRoleAppService _roleAppService;
private readonly IIdentityRoleRepository _roleRepository;
private readonly IOrganizationUnitRepository _organizationUnitRepository;
private readonly OrganizationUnitManager _organization;
public IdentityRoleAppService_Tests()
{
_roleAppService = GetRequiredService<IIdentityRoleAppService>();
_roleRepository = GetRequiredService<IIdentityRoleRepository>();
_organization = GetRequiredService<OrganizationUnitManager>();
_organizationUnitRepository=GetRequiredService<IOrganizationUnitRepository>();
}
[Fact]
@ -81,6 +84,32 @@ namespace Volo.Abp.Identity
role.Name.ShouldBe(input.Name);
}
[Fact]
public async Task CreateWithDetailsAsync()
{
//Arrange
var input = new IdentityRoleCreateDto
{
Name = Guid.NewGuid().ToString("N").Left(8)
};
var orgInput=new OrganizationUnit(
_organization.GuidGenerator.Create(),
Guid.NewGuid().ToString("N").Left(8)
);
//Act
var result = await _roleAppService.CreateAsync(input);
await _organization.CreateAsync(orgInput);
await _organization.AddRoleToOrganizationUnitAsync(result.Id,orgInput.Id);
var orgRolesCount=await _organizationUnitRepository.GetRolesCountAsync(orgInput);
//Assert
orgRolesCount.ShouldBeGreaterThan(0);
}
[Fact]
public async Task UpdateAsync()
{

Loading…
Cancel
Save