public void AcceptAccountGroupAccountRequestTest()
 {
     WebGroupService.TransitAccountGroupAccountRequest t_request = new WebGroupService.TransitAccountGroupAccountRequest();
     t_request.AccountGroupId = _group_id;
     t_request.AccountId      = _user.id;
     t_request.Message        = GetNewString();
     t_request.Id             = EndPoint.CreateOrUpdateAccountGroupAccountRequest(_user.ticket, t_request);
     Assert.IsNotNull(EndPoint.GetAccountGroupAccountRequestById(_user.ticket, t_request.Id));
     EndPoint.AcceptAccountGroupAccountRequest(GetAdminTicket(), t_request.Id, GetNewString());
     Assert.IsNull(EndPoint.GetAccountGroupAccountRequestById(_user.ticket, t_request.Id));
     WebGroupService.TransitAccountGroupAccount[] accounts = EndPoint.GetAccountGroupAccounts(
         GetAdminTicket(), _group_id, null);
     Assert.IsNotNull(accounts);
     Assert.IsTrue(accounts.Length > 0);
     Assert.IsTrue(new TransitServiceCollection <WebGroupService.TransitAccountGroupAccount>(accounts)
                   .ContainsId(_user.id, "AccountId"));
 }
Example #2
0
        public void AcceptAccountGroupAccountInvitationTest()
        {
            // login user
            string      email    = GetNewEmailAddress();
            AccountTest _account = new AccountTest();

            WebAccountService.TransitAccount t_user = _account.GetTransitInstance();
            t_user.Id = _account.EndPoint.CreateAccount(string.Empty, email, t_user);
            Assert.AreNotEqual(0, t_user.Id);
            Console.WriteLine("Created account: {0}", t_user.Id);
            string userticket = _account.Login(email, t_user.Password);

            // join user to group
            WebGroupService.TransitAccountGroupAccount t_account = new WebGroupService.TransitAccountGroupAccount();
            t_account.AccountGroupId  = _group_id;
            t_account.AccountId       = t_user.Id;
            t_account.IsAdministrator = false;
            t_account.Id = EndPoint.CreateOrUpdateAccountGroupAccount(userticket, t_account);
            Assert.AreNotEqual(0, t_account.Id);
            Console.WriteLine("Joined user: {0}", t_account.Id);
            // update the group to private
            WebGroupService.TransitAccountGroup t_group = EndPoint.GetAccountGroupById(GetAdminTicket(), _group_id);
            t_group.IsPrivate = true;
            EndPoint.CreateOrUpdateAccountGroup(GetAdminTicket(), t_group);
            Console.WriteLine("Updated group to private: {0}", _group_id);
            // create an invitatoin for user
            WebGroupService.TransitAccountGroupAccountInvitation t_instance = new WebGroupService.TransitAccountGroupAccountInvitation();
            t_instance.AccountGroupId = _group_id;
            t_instance.AccountId      = _user.id;
            t_instance.RequesterId    = t_account.AccountId;
            t_instance.Message        = GetNewString();
            t_instance.Id             = EndPoint.CreateOrUpdateAccountGroupAccountInvitation(GetAdminTicket(), t_instance);
            Console.WriteLine("Created invitation: {0}", t_instance.Id);
            // make sure the user isn't member of the group
            Assert.IsNull(EndPoint.GetAccountGroupAccountByAccountGroupId(GetAdminTicket(), _user.id, _group_id));
            // get the pending group membership requests
            WebGroupService.TransitAccountGroupAccountRequest[] requests1 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests1.Length);
            // accept invitation
            EndPoint.AcceptAccountGroupAccountInvitation(_user.ticket, t_instance.Id, GetNewString());
            // this has created a new request on the group, it should be +1
            WebGroupService.TransitAccountGroupAccountRequest[] requests2 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests2.Length);
            Assert.AreEqual(requests1.Length + 1, requests2.Length);
            // make sure there's an AccountId in the requests for the user
            WebGroupService.TransitAccountGroupAccountRequest request = null;
            Assert.IsTrue(new TransitServiceCollection <WebGroupService.TransitAccountGroupAccountRequest>(requests2).ContainsId(
                              _user.id, "AccountId", out request));
            Assert.IsNotNull(request);
            Console.WriteLine("New request: {0}", request.Id);
            // accept the request by admin
            EndPoint.AcceptAccountGroupAccountRequest(GetAdminTicket(), request.Id, GetNewString());
            // make sure the invitation was deleted
            Assert.IsNull(EndPoint.GetAccountGroupAccountInvitationById(_user.ticket, t_instance.Id));
            // make sure the request cannot be found any more
            WebGroupService.TransitAccountGroupAccountRequest[] requests3 = EndPoint.GetAccountGroupAccountRequests(
                GetAdminTicket(), _group_id, null);
            Console.WriteLine("Pending requests: {0}", requests3.Length);
            Assert.AreEqual(requests1.Length, requests3.Length);
            // make sure the user is member of the group
            WebGroupService.TransitAccountGroupAccount t_groupaccount = EndPoint.GetAccountGroupAccountByAccountGroupId(
                GetAdminTicket(), _user.id, _group_id);
            Assert.IsNotNull(t_groupaccount);
            Console.WriteLine("Account: {0}", t_groupaccount.Id);
            Assert.AreEqual(t_groupaccount.AccountId, _user.id);
            _account.Delete(GetAdminTicket(), t_user.Id);
        }