public async Task Existing_role_should_be_deleted() { var(resultCreated, roleCreated) = await RoleManagementApi.AddRole(GetUniqueTestRole).UnpackSingleOrDefault(); var deleteResult = await RoleManagementApi.DeleteRole(roleCreated.Id); Assert.True(resultCreated.Success); Assert.True(deleteResult.Success); }
public async Task Created_dto_should_match_original_dto() { var roleDto = GetUniqueTestRole; var(resultCreated, roleCreated) = await RoleManagementApi.AddRole(roleDto).UnpackSingleOrDefault(); Assert.True(resultCreated.Success); Assert.Equal(roleDto.Name, roleCreated.Name); }
public async Task Created_dto_should_match_fetched_dto() { var(resultCreated, roleCreated) = await RoleManagementApi.AddRole(GetUniqueTestRole).UnpackSingleOrDefault(); var(resultFetched, roleFetched) = await RoleManagementApi.GetRoleById(roleCreated.Id).UnpackSingleOrDefault(); Assert.True(resultCreated.Success); Assert.True(resultFetched.Success); Assert.Equal(roleCreated, roleFetched); }
public async Task Role_name_should_be_unique() { var roleDto = GetUniqueTestRole; var resultCreated1 = await RoleManagementApi.AddRole(roleDto); var resultCreated2 = await RoleManagementApi.AddRole(roleDto); Assert.True(resultCreated1.Success); Assert.False(resultCreated2.Success); }
public async Task Service_should_return_all_roles() { var(resultCreated1, roleCreated1) = await RoleManagementApi.AddRole(GetUniqueTestRole).UnpackSingleOrDefault(); var(resultCreated2, roleCreated2) = await RoleManagementApi.AddRole(GetUniqueTestRole).UnpackSingleOrDefault(); var roles = await RoleManagementApi.GetRoles(); var count = roles.Data.Where(x => x.Id == roleCreated1.Id || x.Id == roleCreated2.Id).Count(); Assert.True(resultCreated1.Success); Assert.True(resultCreated2.Success); Assert.Equal(2, count); }
public async Task Role_should_be_fetched_by_normalized_name() { var role = new RoleDto { Name = $"strange Name{Guid.NewGuid()}" }; var(resultCreated, roleCreated) = await RoleManagementApi.AddRole(role).UnpackSingleOrDefault(); var resultSearch = await RoleManagementApi.Search(new RoleSearch(name : roleCreated.NormalizedName)); Assert.True(resultCreated.Success); Assert.True(resultSearch.Success); Assert.Contains(roleCreated, resultSearch.Data); }
private async Task LoadTenantsAndRoles() { var rolesResult = await RoleManagementApi.GetRoles(); var tenantsResult = await TenantManagementApi.GetTenants(); var roles = rolesResult.Data; var tenants = tenantsResult.Data; if (!roles.Any(x => x.Name == Role1.Name)) { var result = await RoleManagementApi.AddRole(Role1); Role1 = result.Data.Single(); } if (!roles.Any(x => x.Name == Role2.Name)) { var result = await RoleManagementApi.AddRole(Role2); Role2 = result.Data.Single(); } if (!tenants.Any(x => x.Name == Tenant1.Name)) { var result = await TenantManagementApi.AddTenant(Tenant1); Tenant1 = result.Data.Single(); } if (!tenants.Any(x => x.Name == Tenant2.Name)) { var result = await TenantManagementApi.AddTenant(Tenant2); Tenant2 = result.Data.Single(); } }
public async Task Deleting_nonexisting_role_should_fail_gracefully() { var deleteResult = await RoleManagementApi.DeleteRole(Guid.NewGuid()); Assert.False(deleteResult.Success); }