/// <summary> /// Gets the names or the roles attached to a user /// </summary> /// <param name="user"></param> /// <returns></returns> public Task <IList <string> > GetRolesAsync(TUser user) { if (user == null) { throw new ArgumentNullException(IdentityConstants.User); } var roles = _userRoleTable.GetRoles(user.Id); { if (roles != null) { return(Task.FromResult <IList <string> >(roles.Select(r => r.Name).ToList())); } } return(Task.FromResult <IList <string> >(null)); }
public void It_creates_and_inserts_new_userrole() { IdentityRole userRole; int result; using (var transaction = _database.GetTransaction()) { var user = _userTable.GetUserByName(name1).FirstOrDefault(); var role = _roleTable.GetRoleByName(role1); result = _userRoleTable.Insert(user.Id, role.Id); userRole = _userRoleTable.GetRoles(user.Id).FirstOrDefault(); transaction.Dispose(); } Assert.AreEqual(1, result); Assert.AreEqual(role1, userRole.Name); }