public void TestMoveTempTicket()
        {
            //Setting up the ticket
            Tickets ticket1 = new Tickets();

            ticket1.id      = 1;
            ticket1.subject = "Test SUbject";
            Tickets ticket2 = new Tickets();

            ticket2.id      = 2;
            ticket2.subject = "Test SUbject 2";
            Tickets ticket3 = new Tickets();

            ticket3.id      = 3;
            ticket3.subject = "Test SUbject 3";
            List <Tickets> listOfTicket = new List <Tickets>();

            listOfTicket.Add(ticket1);
            listOfTicket.Add(ticket2);
            listOfTicket.Add(ticket3);
            TicketResults.tempListOfTikets = listOfTicket;
            //Run function
            TicketResultController.moveTempTickets();
            //Check that there is only one object in the list
            Assert.IsTrue(TicketResults.listOfTickets.Count > 0, "List has more than zero objects after function");
        }
예제 #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);
            }
        }