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"); }
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); }
public void TestClearTempTicketFail() { Tickets ticket = new Tickets(); TicketResults.tempListOfTikets.Add(ticket); //Make sure there is atleast one ticket first Assert.IsTrue(TicketResults.tempListOfTikets.Count > 0, "The count was not greater than 0"); TicketResultController.clearTempTicket(); //Check that there is zero tickets now Assert.AreNotEqual(TicketResults.tempRootTickets.Count, 10); }
public void TestGetDescriptionIsFalse() { //Craete ticket Tickets ticket = new Tickets(); ticket.description = "This is a test Ticket"; ticket.id = 1; TicketResults.listOfTickets.Add(ticket); //run function and get description of the ticket. string description = TicketResultController.getDescription(1); Assert.AreNotEqual(description, "incorrect"); }
//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 TestPopulateTicketsFromRootTickets() { Assert.IsTrue(TicketResults.tempListOfTikets.Count == 0, "The count was not zero"); //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; //Run function TicketResultController.populateTicketFromRootTicket(); Assert.IsTrue(TicketResults.tempListOfTikets.Count > 0, "The count was not zero after function"); }
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); }
//This function will run when a ticket is selected and update the table showing the ticket. protected void showTicket(object sender, EventArgs e) { //Get the Ticket ID int tixID = Int32.Parse(ticketGridView.SelectedRow.Cells[1].Text); //Create a border for the table singleTicketView.Border = 1; //Insert the subject that is part of the grid view ticketSubject.InnerText = ticketGridView.SelectedRow.Cells[2].Text; //Add titles to the table requestorIdLabel.InnerText = "Requestor ID: "; ticketDescriptionLabel.InnerText = "Description: "; priorityLabal.InnerText = "Priority: "; statusLabel.InnerText = "Status: "; subjectLabel.InnerText = "Subject: "; //Add the status of the ticket from the gridView statusStatus.InnerText = ticketGridView.SelectedRow.Cells[4].Text; //Add the priority from the gridView priorityStatus.InnerText = ticketGridView.SelectedRow.Cells[5].Text; //Get the description of the ticket by passing a Ticket ID ticketDescription.InnerText = TicketResultController.getDescription(tixID); requestorId.InnerText = ticketGridView.SelectedRow.Cells[3].Text; }