|
|
|
@ -1,7 +1,4 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Shouldly; |
|
|
|
using Xunit; |
|
|
|
|
|
|
|
@ -19,11 +16,47 @@ public class UserRoleFinder_Tests : AbpIdentityDomainTestBase |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task GetRolesAsync() |
|
|
|
public async Task GetRoleNamesAsync() |
|
|
|
{ |
|
|
|
var roleNames = await _userRoleFinder.GetRolesAsync(_testData.UserJohnId); |
|
|
|
var roleNames = await _userRoleFinder.GetRoleNamesAsync(_testData.UserJohnId); |
|
|
|
roleNames.ShouldNotBeEmpty(); |
|
|
|
roleNames.ShouldContain(x => x == "moderator"); |
|
|
|
roleNames.ShouldContain(x => x == "supporter"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SearchUserAsync() |
|
|
|
{ |
|
|
|
var userResults = await _userRoleFinder.SearchUserAsync("john"); |
|
|
|
userResults.ShouldNotBeEmpty(); |
|
|
|
userResults.ShouldContain(x => x.Id == _testData.UserJohnId); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SearchRoleAsync() |
|
|
|
{ |
|
|
|
var roleResults = await _userRoleFinder.SearchRoleAsync("moderator"); |
|
|
|
roleResults.ShouldNotBeEmpty(); |
|
|
|
roleResults.ShouldContain(x => x.RoleName == "moderator"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SearchUserByIdsAsync() |
|
|
|
{ |
|
|
|
var userResults = await _userRoleFinder.SearchUserByIdsAsync(new[] { _testData.UserJohnId, _testData.UserBobId }); |
|
|
|
userResults.ShouldNotBeEmpty(); |
|
|
|
userResults.Count.ShouldBe(2); |
|
|
|
userResults.ShouldContain(x => x.Id == _testData.UserJohnId && x.UserName == "john.nash"); |
|
|
|
userResults.ShouldContain(x => x.Id == _testData.UserBobId && x.UserName == "bob"); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task SearchRoleByIdsAsync() |
|
|
|
{ |
|
|
|
var roleResults = await _userRoleFinder.SearchRoleByIdsAsync(new[] { _testData.RoleModeratorId, _testData.RoleManagerId }); |
|
|
|
roleResults.ShouldNotBeEmpty(); |
|
|
|
roleResults.Count.ShouldBe(2); |
|
|
|
roleResults.ShouldContain(x => x.RoleName == "moderator"); |
|
|
|
roleResults.ShouldContain(x => x.RoleName == "manager"); |
|
|
|
} |
|
|
|
} |
|
|
|
|