public void TestClearTempRootTicket()
        {
            RootTicket rt = new RootTicket();

            TicketResults.tempRootTickets.Add(rt);
            //Make sure there is atleast one ticket first
            Assert.IsTrue(TicketResults.tempRootTickets.Count > 0, "The count was not greater than 0");
            TicketResultController.clearTempRootTicket();
            //Check that there is zero tickets now
            Assert.AreEqual(TicketResults.tempRootTickets.Count, 0);
        }
Exemple #2
0
        //Function which will load the tickets from a server and save them in appropriate lists.
        private void loadAllTickets(string url)
        {
            RootTicket rt           = new RootTicket();;
            string     valueFromAPI = "";

            //Try create a web request, if it fails throw an error
            try
            {
                //Get the string represenation of response
                valueFromAPI = APIController.callWebRequest(url);
                //COnvert the string to an object
                rt = TicketResultController.convertStringToObject(valueFromAPI);
                //Add the new ticket to the correct Lists
                TicketResultController.addToTemp(rt);
                TicketResultController.moveTempRootTickets();
                TicketResultController.clearTempRootTicket();
                TicketResultController.populateTicketFromRootTicket();
                TicketResultController.moveTempTickets();
                TicketResultController.clearTempTicket();
                //Add the list of tickets as the data source for the grid view.
                ticketGridView.DataSource = TicketResults.listOfTickets;
                //Have the list display 25 tickets on one page.
                ticketGridView.PageSize = 25;
                //Create two event handlers for when then page is changed and when a ticket is selected
                ticketGridView.PageIndexChanging    += handlePageIndexing;
                ticketGridView.SelectedIndexChanged += showTicket;
                //FInally bind all the data to the grid view
                ticketGridView.DataBind();
            }
            catch (WebException we)
            {
                errorMessageLabel.Text = we.Message;
            }
            catch (Exception ex)
            {
                errorMessageLabel.Text = ex.Message;
            }
            //If there is a second page, (Zendesk API only returns a max of 100 per response) call the function again and repeat the process
            if (rt.next_page != null)
            {
                loadAllTickets(rt.next_page);
            }
        }