public void ReportByTicketNoTestDataFound()
        {
            //create an instance of the filtered data
            clsTicketCollection FilteredTicket = new clsTicketCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a name that does not exist
            FilteredTicket.ReportByTicketNo("test1");
            //check that the correct number of records are found
            if (FilteredTicket.Count == 2)
            {
                //Check that the first record is ID 7
                if (FilteredTicket.TicketList[0].TicketID != 7)
                {
                    OK = false;
                }
                //Check that the first record is ID 9
                if (FilteredTicket.TicketList[1].TicketID != 9)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no record
            Assert.IsTrue(OK);
        }
        public void DeleteMethod()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create the item of test data
            clsTicket TestItem = new clsTicket();
            //var to store the primarykey
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.TicketID           = 1;
            TestItem.TicketPurchaseDate = DateTime.Now.Date;
            TestItem.TicketNo           = "ASD456GH";
            TestItem.FlightNo           = 535;
            TestItem.SeatNo             = "53B";
            //set thisticket to the test data
            AllTicket.ThisTicket = TestItem;
            //add the record
            PrimaryKey = AllTicket.Add();
            //set the primary key of the test data
            TestItem.TicketID = PrimaryKey;
            //find the record
            AllTicket.ThisTicket.Find(PrimaryKey);
            //delete the record
            AllTicket.Delete();
            //now find the record
            Boolean Found = AllTicket.ThisTicket.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Example #3
0
    //function for updating new records
    void Update()
    {
        //create an instance of the Ticket Book
        clsTicketCollection TicketBook = new clsTicketCollection();
        //validate the data on the web form
        string Error = TicketBook.ThisTicket.Valid(txtTicketPurchaseDate.Text, txtTicketNo.Text, txtFlightNo.Text, txtSeatNo.Text);

        //if the data is ok then add it to the object
        if (Error == "")
        {
            //find the record to update
            TicketBook.ThisTicket.Find(TicketID);
            //get the data entered by the user
            TicketBook.ThisTicket.TicketPurchaseDate = Convert.ToDateTime(txtTicketPurchaseDate.Text);
            TicketBook.ThisTicket.TicketNo           = txtTicketNo.Text;
            TicketBook.ThisTicket.FlightNo           = Convert.ToInt32(txtFlightNo.Text);
            TicketBook.ThisTicket.SeatNo             = txtSeatNo.Text;
            //update the record
            TicketBook.Update();
            //all done so redirect back to the main page
            Response.Redirect("TicketList.aspx");
        }
        else
        {
            //report the error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
    Int32 DisplayTicket(string TicketNoFilter)
    {
        //var to store the TicketNo
        string TicketNo;
        //create an instance of the Orderline collection class
        clsTicketCollection Ticket = new clsTicketCollection();

        Ticket.ReportByTicketNo(TicketNoFilter);
        //var to store the count of records
        Int32 RecordCount;
        //var to store the index for the loop
        Int32 Index = 0;

        //get the count of records
        RecordCount = Ticket.Count;
        //clear the list box
        lstTicket.Items.Clear();
        //while there are records
        while (Index < RecordCount)
        {
            //get the Ticket no
            TicketNo = Ticket.TicketList[Index].TicketNo;
            //create a new entry for the list box
            ListItem NewEntry = new ListItem(TicketNo + " ".ToString());
            //add the staff to the list
            lstTicket.Items.Add(NewEntry);
            //move the index to the next record
            Index++;
        }
        //return to the count of records found
        return(RecordCount);
    }
        public void UpdateMethod()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create the item of test data
            clsTicket TestItem = new clsTicket();
            //var to store the primarykey
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.TicketPurchaseDate = DateTime.Now.Date;
            TestItem.TicketNo           = "ASD456GH";
            TestItem.FlightNo           = 535;
            TestItem.SeatNo             = "53B";
            //set thisticket to the test data
            AllTicket.ThisTicket = TestItem;
            //add the record
            PrimaryKey = AllTicket.Add();
            //set the primary key of the test data
            TestItem.TicketID = PrimaryKey;
            //modify the test data
            TestItem.TicketPurchaseDate = DateTime.Now.Date;
            TestItem.TicketNo           = "HGF3F72";
            TestItem.FlightNo           = 767;
            TestItem.SeatNo             = "5B";
            //Set the record based on the new test data
            AllTicket.ThisTicket = TestItem;
            //update the record
            AllTicket.Update();
            //find the record
            AllTicket.ThisTicket.Find(PrimaryKey);
            //test to see this ticket matches the test data
            Assert.AreEqual(AllTicket.ThisTicket, TestItem);
        }
        public void AddMethod()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create the item of test data
            clsTicket TestItem = new clsTicket();
            //var to store the primarykey
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.TicketID           = 1;
            TestItem.TicketPurchaseDate = DateTime.Now.Date;
            TestItem.TicketNo           = "ASD456GH";
            TestItem.FlightNo           = 535;
            TestItem.SeatNo             = "53B";
            //set thisticket to the test data
            AllTicket.ThisTicket = TestItem;
            //add the record
            PrimaryKey = AllTicket.Add();
            //set the primary key of the test data
            TestItem.TicketID = PrimaryKey;
            //find the record
            AllTicket.ThisTicket.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllTicket.ThisTicket, TestItem);
        }
        public void AddMethodOK()
        {
            //Create an instance of the class we want to create
            clsTicketCollection AllTickets = new clsTicketCollection();
            //Create the item of test data
            clsTicket TestItem = new clsTicket();
            //Variable to store the primary kjey
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.CustomerID  = 1;
            TestItem.ScreeningID = 1;
            TestItem.Validated   = false;
            TestItem.Cancelled   = false;
            //Set ThisFilm to the test data
            AllTickets.ThisTicket = TestItem;
            //Add the record
            PrimaryKey = AllTickets.Add();
            //Set the primary key of the test data
            TestItem.TicketID = PrimaryKey;
            //Find the record
            AllTickets.ThisTicket.Find(PrimaryKey);
            //Test to see that the two values are the same
            Assert.AreEqual(AllTickets.ThisTicket, TestItem);
        }
        public void InstanceOK()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();

            //test to see that it exists
            Assert.IsNotNull(AllTicket);
        }
        public void InstanceOK()
        {
            //Create an instance of the class we want to create
            clsTicketCollection AllTickets = new clsTicketCollection();

            //Test to see that it exists
            Assert.IsNotNull(AllTickets);
        }
        public void ReportByTicketNoNoneFound()
        {
            //create an instance of the class containing unfiltered results
            clsTicketCollection FilteredTicket = new clsTicketCollection();

            //apply a ticket no that doesnt exist
            FilteredTicket.ReportByTicketNo("XXXXXX");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredTicket.Count);
        }
Example #11
0
    void DeleteTicket()
    {
        //function to delete the selected record

        //create a new instance of the Ticket book
        clsTicketCollection TicketBook = new clsTicketCollection();

        //find the record to delete
        TicketBook.ThisTicket.Find(TicketID);
        //delete the record
        TicketBook.Delete();
    }
        public void ReportByTicketNo()
        {
            //create an instance of the class containing unfiltered results
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create an instance of the filtered data
            clsTicketCollection FilteredTicket = new clsTicketCollection();

            //apply a blank string (should return all records)
            FilteredTicket.ReportByTicketNo("");
            //test to see that the two values are the same
            Assert.AreEqual(AllTicket.Count, FilteredTicket.Count);
        }
Example #13
0
    void DisplayTicket()
    {
        //create an instance of the Ticket Book
        clsTicketCollection TicketBook = new clsTicketCollection();

        //find the record to update
        TicketBook.ThisTicket.Find(TicketID);
        //display the data for the this record
        txtTicketPurchaseDate.Text = TicketBook.ThisTicket.TicketPurchaseDate.ToString();
        txtTicketNo.Text           = TicketBook.ThisTicket.TicketNo;
        txtFlightNo.Text           = TicketBook.ThisTicket.FlightNo.ToString();
        txtSeatNo.Text             = TicketBook.ThisTicket.SeatNo;
    }
    void DisplayTicket()
    {
        //create an instance of a class
        clsTicketCollection Ticket = new clsTicketCollection();

        //set the data source to the list of tickets in the collection
        lstTicket.DataSource = Ticket.TicketList;
        //set the name of the primary key
        lstTicket.DataValueField = "TicketID";
        //set the data field to display
        lstTicket.DataTextField = "TicketNo";
        //bind the data to the list
        lstTicket.DataBind();
    }
        public void ThisTicketPropertyOK()
        {
            //Create an instance of the class we want to create
            clsTicketCollection AllTickets = new clsTicketCollection();
            //Create some test data to assign to the property
            clsTicket TestItem = new clsTicket();

            //Set the properties of the test object
            TestItem.CustomerID  = 1;
            TestItem.ScreeningID = 1;
            TestItem.Validated   = false;
            TestItem.Cancelled   = false;
            //Assign the data to the property
            AllTickets.ThisTicket = TestItem;
            //Test to see that the two values are the same
            Assert.AreEqual(AllTickets.ThisTicket, TestItem);
        }
        public void ThisTicketProperty()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create some test data to assign to the property
            clsTicket TestTicket = new clsTicket();

            //set the properties of the test object
            TestTicket.TicketID           = 1;
            TestTicket.TicketPurchaseDate = DateTime.Now.Date;
            TestTicket.TicketNo           = "ASD456GH";
            TestTicket.FlightNo           = 535;
            TestTicket.SeatNo             = "53B";
            //assign the data to the property
            AllTicket.ThisTicket = TestTicket;
            //test to see that the two values are the same
            Assert.AreEqual(AllTicket.ThisTicket, TestTicket);
        }
        public void ListAndCountOK()
        {
            //Create an instance of the class we want to create
            clsTicketCollection AllTickets = new clsTicketCollection();
            //Create some test data to assign to the property
            //In this case the data needs to be a list of objects
            List <clsTicket> TestList = new List <clsTicket>();
            //Add an item to the list
            //Create the item of test data
            clsTicket TestItem = new clsTicket();

            //Set its properties
            TestItem.CustomerID  = 1;
            TestItem.ScreeningID = 1;
            TestItem.Validated   = false;
            TestItem.Cancelled   = false;
            //Add the item to the test list
            TestList.Add(TestItem);
            //Assign the data to the property
            AllTickets.TicketList = TestList;
            //Test to see that the two values are the same
            Assert.AreEqual(AllTickets.Count, TestList.Count);
        }
        public void ListAndCount()
        {
            //create an instance of a class
            clsTicketCollection AllTicket = new clsTicketCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsTicket> TestList = new List <clsTicket>();
            //add an item to the list
            //create the item of test data
            clsTicket TestItem = new clsTicket();

            //set its properties
            TestItem.TicketID           = 1;
            TestItem.TicketPurchaseDate = DateTime.Now.Date;
            TestItem.TicketNo           = "ASD456GH";
            TestItem.FlightNo           = 535;
            TestItem.SeatNo             = "53B";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllTicket.TicketList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllTicket.Count, TestList.Count);
        }