예제 #1
0
 public Invitation InviteMember(Player inviter, Player invitee, Group group)
 {
     group.PlayerPermissions = new List<PlayerPermission> { };
     if (group.PlayerPermissions.Any(playerPermission
         => (playerPermission.Player == inviter)
         && (playerPermission.Group == group)
         && (playerPermission.Permission.Name == "InviteMembers")))
     {
         Invitation invitation = new Invitation();
         invitation.Inviter = inviter;
         invitation.Invitee = invitee;
         invitation.Group = group;
         return invitation;
     }
     else return null;
 }
예제 #2
0
 public Group CreateGroupAndPlayer(string playerName)
 {
     Group group = new Group();
     var player = new Player();
     player.Name = playerName;
     player.Groups = new List<Group> { group };
     group.Members = new List<Player> { player };
     group.PlayerPermissions = new List<PlayerPermission>
     {
         new PlayerPermission
         {
             Group = group,
             Permission = new Permission
             {
                 Name = "InviteMembers",
             },
             Player = player
         }
     };
     return group;
 }
예제 #3
0
 public void InviteMember_When_Have_No_Permission_Should_Return_Null()
 {
     var groupOperations = new GroupOperations();
     Player inviter = new Player();
     Player invitee = new Player();
     Group group = new Group();
     Invitation invitation = groupOperations.InviteMember(inviter, invitee, group);
     Assert.IsNull(invitation);
 }
예제 #4
0
 public void InviteMember_Should_Return_Invitation()
 {
     var groupOperations = new GroupOperations();
     Player inviter = new Player();
     Player invitee = new Player();
     Group group = new Group();
     Invitation invitation = groupOperations.InviteMember(inviter, invitee, group);
     Assert.AreEqual(inviter, invitation.Inviter);
     Assert.AreEqual(invitee, invitation.Invitee);
     Assert.AreEqual(group, invitation.Group);
 }