public Object ResolveArgumentGroup(IActor resolvedActor, String[] parameters) { if (resolvedActor == null) { if (parameters.Length != 1) { throw new SystemException("argument group expects exactly one parameter instead of " + parameters.Length); } String groupId = parameters[0]; IGroup group = null; try { group = organizationService.FindGroupById(groupId); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve group-argument with parameter " + groupId + " : " + e.Message); } return(group); } else { if (parameters.Length != 1) { throw new SystemException("argument group expects exactly one parameter (membership-type) instead of " + parameters.Length); } IUser user = null; IGroup group = null; String membershipType = parameters[0]; try { group = organizationService.FindGroupByMembership(resolvedActor.Id, membershipType); } catch (InvalidCastException e) { throw new SystemException("can't resolve group-argument : a group must be calculated from a User, not a " + resolvedActor.GetType().FullName, e); } catch (OrganisationRuntimeException e) { throw new SystemException("can't resolve group-argument : can't find the hierarchy-memberschip of User " + user.Id + " and membership-type " + membershipType + " : " + e.Message, e); } return(group); } }
public void TestFindGroupByMembership() { IGroup group = orgComp.FindGroupByMembership("ed", "hierarchy"); Assert.AreEqual("Research & Development", group.Name); }