public async Task Delete_Correct() { var service = new UserRoleAppService(this.CreateDbContext); var roleId = CreateId(); var userId = CreateId(); using (var db = this.CreateDbContext()) { db.UserRoles.Add(new UserRole() { UserID = userId, RoleID = roleId }); await db.SaveChangesAsync(); } await service.DeleteRoleUsersAsync(roleId, new List <string>() { userId }); var result = await service.FindUsersByRoleIdAsync(roleId); Assert.IsNotNull(result); Assert.IsTrue(result.Count == 0); }
public async Task FindUsers_Correct() { var service = new UserRoleAppService(this.CreateDbContext); var userId = CreateId(); var roleId = CreateId(); var systemRole = new SystemRole() { ClientIds = "1,2,3", ID = roleId, Name = "Name" }; var userRole = new UserRole() { RoleID = roleId, UserID = userId }; using (var db = this.CreateDbContext()) { db.SystemRoles.Add(systemRole); db.UserRoles.Add(userRole); await db.SaveChangesAsync(); } var userIds = await service.FindUsersByRoleIdAsync(roleId); Assert.IsNotNull(userIds); Assert.IsTrue(userIds.Count == 1); Assert.IsTrue(userIds[0].UserID == userId); using (var db = this.CreateDbContext()) { db.SystemRoles.Remove(systemRole); db.UserRoles.Remove(userRole); await db.SaveChangesAsync(); } }