public void AcceptGroupMemberRequest() { var groupMemberName = "AcceptGroupMemberRequest"; var requestor = CreateUser(groupMemberName + " Requestor"); var acceptor = CreateGroup(groupMemberName + " Acceptor"); var newMember = CreateRelationshipRequest(requestor.Id, acceptor.Id); _relationshipController.UpdateRequest(newMember, true); var groupRequests = _relationshipController.GetRelationRequestorActors(newMember.AcceptorId, ActorType.User); var matches = groupRequests.Count(g => g.Name == groupMemberName + " Requestor"); Assert.Equal(matches, 0); var groupMembers = _relationshipController.GetRelatedActors(newMember.AcceptorId, ActorType.User); matches = groupMembers.Count(g => g.Name == groupMemberName + " Requestor"); Assert.Equal(matches, 1); var userGroups = _relationshipController.GetRelatedActors(newMember.RequestorId, ActorType.Group); matches = userGroups.Count(g => g.Name == groupMemberName + " Acceptor"); Assert.Equal(matches, 1); }
public void AcceptUserFriendRequest() { var userFriendName = "AcceptUserFriendRequest"; var requestor = Helpers.CreateUser(userFriendName + " Requestor"); var acceptor = Helpers.CreateUser(userFriendName + " Acceptor"); var newFriend = CreateRelationship(requestor.Id, acceptor.Id); var userRequests = _relationshipController.GetRelationRequestorActors(newFriend.AcceptorId, ActorType.User); var matches = userRequests.Count(g => g.Name == userFriendName + " Requestor"); Assert.Equal(matches, 0); var userFriends = _relationshipController.GetRelatedActors(newFriend.RequestorId, ActorType.User); matches = userFriends.Count(g => g.Name == userFriendName + " Acceptor"); Assert.Equal(matches, 1); }
protected float Evaluate(int gameId, int actorId, EvaluationCriteria completionCriteria, ActorType actorType, EvaluationType evaluationType) { switch (completionCriteria.Scope) { case CriteriaScope.Actor: switch (completionCriteria.EvaluationDataType) { case EvaluationDataType.Boolean: return(EvaluateBool(gameId, actorId, completionCriteria)); case EvaluationDataType.String: return(EvaluateString(gameId, actorId, completionCriteria)); case EvaluationDataType.Float: return(EvaluateFloat(gameId, actorId, completionCriteria)); case EvaluationDataType.Long: return(EvaluateLong(gameId, actorId, completionCriteria)); default: return(0); } case CriteriaScope.RelatedUsers: var relatedUsers = RelationshipCoreController.GetRelatedActors(actorId, ActorType.User).Select(a => a.Id).ToList(); if (actorType == ActorType.User) { relatedUsers.Add(actorId); relatedUsers = relatedUsers.Distinct().ToList(); } switch (completionCriteria.EvaluationDataType) { case EvaluationDataType.Boolean: return(EvaluateManyBool(gameId, relatedUsers, completionCriteria)); case EvaluationDataType.String: return(EvaluateManyString(gameId, relatedUsers, completionCriteria)); case EvaluationDataType.Float: return(EvaluateManyFloat(gameId, relatedUsers, completionCriteria)); case EvaluationDataType.Long: return(EvaluateManyLong(gameId, relatedUsers, completionCriteria)); default: return(0); } case CriteriaScope.RelatedGroups: if (actorType == ActorType.User) { throw new NotImplementedException("RelatedGroups Scope is only implemented for groups"); } var relatedGroups = RelationshipCoreController.GetRelatedActors(actorId, ActorType.Group).Select(a => a.Id).ToList(); relatedGroups.Add(actorId); relatedGroups = relatedGroups.Distinct().ToList(); switch (completionCriteria.EvaluationDataType) { case EvaluationDataType.Boolean: return(EvaluateManyBool(gameId, relatedGroups, completionCriteria)); case EvaluationDataType.String: return(EvaluateManyString(gameId, relatedGroups, completionCriteria)); case EvaluationDataType.Float: return(EvaluateManyFloat(gameId, relatedGroups, completionCriteria)); case EvaluationDataType.Long: return(EvaluateManyLong(gameId, relatedGroups, completionCriteria)); default: return(0); } case CriteriaScope.RelatedGroupUsers: if (actorType == ActorType.User) { throw new NotImplementedException("RelatedGroupUsers Scope is only implemented for groups"); } var groups = RelationshipCoreController.GetRelatedActors(actorId, ActorType.Group).Select(a => a.Id).ToList(); groups.Add(actorId); groups = groups.Distinct().ToList(); var relatedGroupUsers = groups.SelectMany(g => RelationshipCoreController.GetRelatedActors(g, ActorType.User).Select(a => a.Id)).Distinct().ToList(); switch (completionCriteria.EvaluationDataType) { case EvaluationDataType.Boolean: return(EvaluateManyBool(gameId, relatedGroupUsers, completionCriteria)); case EvaluationDataType.String: return(EvaluateManyString(gameId, relatedGroupUsers, completionCriteria)); case EvaluationDataType.Float: return(EvaluateManyFloat(gameId, relatedGroupUsers, completionCriteria)); case EvaluationDataType.Long: return(EvaluateManyLong(gameId, relatedGroupUsers, completionCriteria)); default: return(0); } default: return(0); } }