Exemplo n.º 1
0
    public void getTickets()
    {
        rootticket = null;
        ticket     = null;
        if (rootticket == null)
        {
            rootticket = new RootTicket();
        }
        itemData = JsonMapper.ToObject(ticketsData.text);
        int n = itemData["tickets"].Count;

        for (int i = 0; i < n; i++)
        {
            ticket              = new Ticket();
            ticket.id           = int.Parse(itemData["tickets"][i]["id"].ToString());
            ticket.tickettitle  = itemData["tickets"][i]["tickettitle"].ToString();
            ticket.ticketdesc   = itemData["tickets"][i]["ticketdesc"].ToString();
            ticket.creationdate = itemData["tickets"][i]["creationdate"].ToString();
            ticket.status       = itemData["tickets"][i]["status"].ToString();
            ticket.sprint       = int.Parse(itemData["tickets"][i]["sprint"].ToString());
            //if(itemData["tickets"][i]["solution"].ToString() != "") {
            //    ticket.solution = itemData["tickets"][i]["solution"].ToString();
            //}
            ticket.idBoard = int.Parse(itemData["tickets"][i]["idBoard"].ToString());
            rootticket.tickets.Add(ticket);
        }
    }
        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);
        }
Exemplo n.º 3
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);
            }
        }
        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);
        }
 /// <summary>
 /// Add the root ticket to the list
 /// </summary>
 /// <param name="rt">RootTicket Object</param>
 public static void addToTemp(RootTicket rt)
 {
     TicketResults.tempRootTickets.Add(rt);
 }
        /// <summary>
        /// Convert a stream of string to a rootTicket Object
        /// </summary>
        /// <param name="streamOfObject">a stream of strings </param>
        /// <returns>A RootTicket Object</returns>
        public static RootTicket convertStringToObject(string streamOfObject)
        {
            RootTicket rootTickets = new RootTicket();

            return(JsonConvert.DeserializeObject <RootTicket>(streamOfObject));
        }