//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); } }
public void TestMoveTempRootTicketFail() { //Setting up Tickets and lists. RootTicket rt = new RootTicket(); Tickets ticket = new Tickets(); ticket.id = 1; ticket.subject = "Test SUbject"; List <Tickets> list = new List <Tickets>(); list.Add(ticket); rt.tickets = list; List <RootTicket> rtList = new List <RootTicket>(); rtList.Add(rt); TicketResults.tempRootTickets = rtList; //show that the two lists are not equal Assert.AreNotEqual(TicketResults.tempRootTickets, TicketResults.listOfRootTicket); //Run function TicketResultController.moveTempRootTickets(); //Check that there is only one object in the list Assert.AreNotEqual(TicketResults.listOfRootTicket.Count, 5); }