public void CreateAccountInvitationTest() { // create an invitation from admin to a new user WebAccountService.TransitAccountInvitation t_instance = GetTransitInstance(); t_instance.Id = Create(GetAdminTicket(), t_instance); // sign-up with this invitation WebAccountService.TransitAccount t_account = new WebAccountService.TransitAccount(); t_account.Name = GetNewString(); t_account.Password = GetNewString(); t_account.Birthday = DateTime.UtcNow.AddYears(-10); try { int impossible_id = EndPoint.CreateAccountWithInvitation(t_instance.Id, GetNewString(), t_account); Assert.IsTrue(false, "Invalid code should have thrown an exception."); } catch (Exception) { } try { int impossible_id = EndPoint.CreateAccountWithInvitation(-1, t_instance.Code, t_account); Assert.IsTrue(false, "Invalid id should have thrown an exception."); } catch (Exception) { } string ticket = EndPoint.CreateAccountWithInvitationAndLogin(t_instance.Id, t_instance.Code, t_account); Assert.IsFalse(string.IsNullOrEmpty(ticket)); int id = EndPoint.GetAccountId(ticket); Assert.IsTrue(id > 0); Console.WriteLine("New account: {0}", id); WebAccountService.TransitAccountInvitation t_instance_deleted = EndPoint.GetAccountInvitationById(GetAdminTicket(), t_instance.Id); Assert.IsNull(t_instance_deleted, "Invitation hasn't been deleted after the account was created."); EndPoint.DeleteAccount(ticket, id); }