public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create the item of test data
            clsFlights TestItem = new clsFlights();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FlightNo         = "AA11";
            TestItem.Airline          = "Air India";
            TestItem.ArrivalAirport   = "DXB";
            TestItem.Arrival          = DateTime.Now.Date;
            TestItem.Departure        = DateTime.Now.Date;
            TestItem.DepartureAirport = "MCR";
            TestItem.Destination      = "Dubai";
            //set ThisFlights to the test data
            AllFlights.ThisFlight = TestItem;
            //add the record
            PrimaryKey = AllFlights.Add();
            //set the primary key of the test data
            TestItem.FlightID = PrimaryKey;
            //find the record
            AllFlights.ThisFlight.Find(PrimaryKey);
            //delete the record
            AllFlights.Delete();
            //now find the record
            Boolean Found = AllFlights.ThisFlight.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
    Int32 DisplayFlight(string DateOfBirthFilter)
    {
        //var to store the Dateofbirth
        string DateOfBirth;
        //create an instance of the Orderline collection class
        clsFlightCollection Flight = new clsFlightCollection();

        Flight.ReportByDateOfBirth(DateOfBirthFilter);
        //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 = Flight.Count;
        //clear the list box
        lstFlight.Items.Clear();
        //while there are records
        while (Index < RecordCount)
        {
            //get the Dateofbirth
            DateOfBirth = Flight.FlightList[Index].DateOfBirth;
            //create a new entry for the list box
            ListItem NewEntry = new ListItem(DateOfBirth + " ".ToString());
            //add the staff to the list
            lstFlight.Items.Add(NewEntry);
            //move the index to the next record
            Index++;
        }
        //return to the count of records found
        return(RecordCount);
    }
Esempio n. 3
0
        public void AddMethod()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create the item of test data
            clsFlight TestItem = new clsFlight();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FlightID      = 1;
            TestItem.TicketID      = 2;
            TestItem.DateOfBirth   = "1st May 2000";
            TestItem.Gate          = "12B";
            TestItem.DepartureDate = DateTime.Now.Date;
            //set thisflight to the test data
            AllFlight.ThisFlight = TestItem;
            //add the record
            PrimaryKey = AllFlight.Add();
            //set the primary key of the test data
            TestItem.FlightID = PrimaryKey;
            //find the record
            AllFlight.ThisFlight.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllFlight.ThisFlight, TestItem);
        }
Esempio n. 4
0
        public void DeleteMethod()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create the item of test data
            clsFlight TestItem = new clsFlight();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FlightID      = 1;
            TestItem.TicketID      = 2;
            TestItem.DateOfBirth   = "1st May 2000";
            TestItem.Gate          = "12B";
            TestItem.DepartureDate = DateTime.Now.Date;
            //set thisflight to the test data
            AllFlight.ThisFlight = TestItem;
            //add the record
            PrimaryKey = AllFlight.Add();
            //set the primary key of the test data
            TestItem.FlightID = PrimaryKey;
            //find the record
            AllFlight.ThisFlight.Find(PrimaryKey);
            //delete the record
            AllFlight.Delete();
            //now find the record
            Boolean Found = AllFlight.ThisFlight.Find(PrimaryKey);

            //test to see that record was not found
            Assert.IsFalse(Found);
        }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create the item of test data
            clsFlights TestFlights = new clsFlights();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            //set its properties
            //TestFlights.FlightID = 1;
            TestFlights.FlightNo         = "AA11";
            TestFlights.Airline          = "Air India";
            TestFlights.ArrivalAirport   = "DXB";
            TestFlights.Arrival          = DateTime.Now.Date;
            TestFlights.Departure        = DateTime.Now.Date;
            TestFlights.DepartureAirport = "MCR";
            TestFlights.Destination      = "Dubai";
            //set ThisFlights to the test data
            AllFlights.ThisFlight = TestFlights;
            //add the record
            PrimaryKey = AllFlights.Add();
            //set the primary key of the test data
            TestFlights.FlightID = PrimaryKey;
            //find the record
            AllFlights.ThisFlight.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllFlights.ThisFlight, TestFlights);
        }
        public void FilterByDestinationTestDataFound()
        {
            //create an instance of the filtered data
            clsFlightCollection FilteredFlights = new clsFlightCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a destination that doesn't exist
            FilteredFlights.FilterByDestination("XXXXX");
            //check that the correct number of records are found
            if (FilteredFlights.Count == 2)
            {
                //check that the first record is ID 36
                if (FilteredFlights.FlightList[0].FlightID != 24)
                {
                    OK = false;
                }
                //check that the first record is ID 37
                if (FilteredFlights.FlightList[1].FlightID != 31)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
Esempio n. 7
0
        void Update40()
        {
            //create an instance of the flight book
            MyClassLibrary.clsFlightCollection Flights = new clsFlightCollection();
            //validate the data on the web form
            //Valid(string flightNo, string airline, string destination, string arrival, string arrivalAirport, string departure, string departureAirport)
            string Error = Flights.ThisFlight.Valid(txtFlightNo.Text, txtAirline.Text, txtDestination.Text, txtArrivalTime.Text, txtArrival.Text, txtDepartureTime.Text, txtDeparture.Text);

            //if the data is OK then add it to the object
            if (Error == "")

            {
                //get the data entered by the user
                Flights.ThisFlight.Find(FlightID);
                Flights.ThisFlight.FlightNo         = txtFlightNo.Text;
                Flights.ThisFlight.Airline          = txtAirline.Text;
                Flights.ThisFlight.Destination      = txtDestination.Text;
                Flights.ThisFlight.ArrivalAirport   = txtArrivalTime.Text;
                Flights.ThisFlight.Arrival          = Convert.ToDateTime(txtArrivalTime.Text);
                Flights.ThisFlight.Departure        = Convert.ToDateTime(txtDepartureTime.Text);
                Flights.ThisFlight.DepartureAirport = txtDepartureTime.Text;

                //add the record
                Flights.Update();
                //all done so redirect back to the main page
                //Response.Redirect("frmFlightsMain.cs");
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered" + Error;
            }
        }
Esempio n. 8
0
        public void UpdateMethod()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create the item of test data
            clsFlight TestItem = new clsFlight();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.TicketID      = 2;
            TestItem.DateOfBirth   = "1st May 2000";
            TestItem.Gate          = "12B";
            TestItem.DepartureDate = DateTime.Now.Date;
            //set thisflight to the test data
            AllFlight.ThisFlight = TestItem;
            //add the record
            PrimaryKey = AllFlight.Add();
            //set the primary key of the test data
            TestItem.FlightID = PrimaryKey;
            //modify the test data
            TestItem.TicketID      = 3;
            TestItem.DateOfBirth   = "11th April 2001";
            TestItem.Gate          = "1D";
            TestItem.DepartureDate = DateTime.Now.Date;
            //set the record based on the new test data
            AllFlight.ThisFlight = TestItem;
            //update the record
            AllFlight.Update();
            //find the record
            AllFlight.ThisFlight.Find(PrimaryKey);
            //test to see thisflight matches the test data
            Assert.AreEqual(AllFlight.ThisFlight, TestItem);
        }
    //function for updating new records
    void Update()
    {
        //create an instance of the Ticket Book
        clsFlightCollection FlightBook = new clsFlightCollection();
        //validate the data on the web form
        string Error = FlightBook.ThisFlight.Valid(txtDateOfBirth.Text, txtGate.Text, txtDepartureDate.Text);

        //if the data is ok then add it to the object
        if (Error == "")
        {
            //get the data entered by the user
            FlightBook.ThisFlight.DateOfBirth   = txtDateOfBirth.Text;
            FlightBook.ThisFlight.Gate          = txtGate.Text;
            FlightBook.ThisFlight.DepartureDate = Convert.ToDateTime(txtDepartureDate.Text);
            //update the record
            FlightBook.Update();
            //all done so redirect back to the main page
            Response.Redirect("FlightList.aspx");
        }
        else
        {
            //report the error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsFlights> TestList = new List <clsFlights>();
            //add an item to the list
            //create the item of test data
            clsFlights TestItem = new clsFlights();

            //set its properties
            TestItem.FlightID         = 1;
            TestItem.FlightNo         = "A114";
            TestItem.Airline          = "Air India";
            TestItem.ArrivalAirport   = "BHX";
            TestItem.Arrival          = DateTime.Now.Date;
            TestItem.Departure        = DateTime.Now.Date;
            TestItem.DepartureAirport = "BHX";
            TestItem.Destination      = "India";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllFlights.FlightList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllFlights.Count, TestList.Count);
        }
Esempio n. 11
0
        public void ReportByDateOFBirthTestDataFound()
        {
            //create an instance of the filtered data
            clsFlightCollection FilteredFlight = new clsFlightCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a name that doesnt exist
            FilteredFlight.ReportByDateOfBirth("June 2020");
            //check that the correct number of records are found
            if (FilteredFlight.Count == 2)
            {
                //check of the record is ID 8
                if (FilteredFlight.FlightList[0].FlightID != 20)
                {
                    OK = false;
                }
                //check that the first record is ID 10
                if (FilteredFlight.FlightList[1].FlightID != 22)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
Esempio n. 12
0
        //function for adding new records
        void Add()
        {
            //create an instance of the flight book
            MyClassLibrary.clsFlightCollection Flights = new clsFlightCollection();
            //validate the data on the web form
            string Error = Flights.ThisFlight.Valid(txtFlightNo.Text, txtAirline.Text, txtDestination.Text, txtArrivalTime.Text, txtArrival.Text, txtDepartureTime.Text, txtDeparture.Text);

            //if the data is OK then add it to the object
            if (Error == "")
            {
                //get the data entered by the user
                Flights.ThisFlight.FlightNo         = txtFlightNo.Text;
                Flights.ThisFlight.Airline          = txtAirline.Text;
                Flights.ThisFlight.Destination      = txtDestination.Text;
                Flights.ThisFlight.ArrivalAirport   = txtArrival.Text;
                Flights.ThisFlight.Arrival          = Convert.ToDateTime(txtArrivalTime.Text);
                Flights.ThisFlight.Departure        = Convert.ToDateTime(txtDepartureTime.Text);
                Flights.ThisFlight.DepartureAirport = txtDeparture.Text;

                //add the record
                Flights.Add();
                //all done so redirect back to the main page
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered" + Error;
            }
        }
    //This function handles the load event for the page
    protected void Page_Load(object sender, EventArgs e)
    {
        //if this is the first time the page is displayed
        if (IsPostBack == false)
        {
            //update the list box
            DisplayFlight();
        }


        void DisplayFlight()
        {
            //create an instance of the collection class
            clsFlightCollection Flight = new clsFlightCollection();

            //set the data source to the list of flights in the collection
            lstFlight.DataSource = Flight.FlightList;
            //set the name of the primary key
            lstFlight.DataValueField = "FlightID";
            //set the data field to display
            lstFlight.DataTextField = "DateOfBirth";
            //bind the data to the list
            lstFlight.DataBind();
        }
    }
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();

            //test to see that it exists
            Assert.IsNotNull(AllFlights);
        }
Esempio n. 15
0
        public void InstanceOK()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();

            //test to see that it exists
            Assert.IsNotNull(AllFlight);
        }
Esempio n. 16
0
        public void ReportByDateOfBirthNoneFound()
        {
            //create an instance of the filtered data
            clsFlightCollection FilteredFlight = new clsFlightCollection();

            //apply a date of birth that doesnt exist
            FilteredFlight.ReportByDateOfBirth("xxx xxxx xxxx");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredFlight.Count);
        }
        public void FilterByDestinationNoneFound()
        {
            //create an instance of the filtered data
            clsFlightCollection FilteredFlights = new clsFlightCollection();

            //apply a airline that doesn't exist
            FilteredFlights.FilterByDestination("@@@");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredFlights.Count);
        }
Esempio n. 18
0
    void DeleteFlight()
    {
        //function to delete the selected record

        //create a new instance of the Booking book
        clsFlightCollection FlightBook = new clsFlightCollection();

        //find the record to delete
        FlightBook.ThisFlight.Find(FlightID);
        //delete the record
        FlightBook.Delete();
    }
Esempio n. 19
0
 void DisplayFlight()
 {
     MyClassLibrary.clsFlightCollection Flights = new clsFlightCollection();
     Flights.ThisFlight.Find(FlightID);
     txtFlightNo.Text      = Flights.ThisFlight.FlightNo;
     txtAirline.Text       = Flights.ThisFlight.Airline;
     txtDestination.Text   = Flights.ThisFlight.Destination;
     txtArrival.Text       = Flights.ThisFlight.ArrivalAirport;
     txtArrivalTime.Text   = Flights.ThisFlight.Arrival.ToString();
     txtDepartureTime.Text = Flights.ThisFlight.Departure.ToString();
     txtDeparture.Text     = Flights.ThisFlight.DepartureAirport;
 }
    void DisplayFlight()
    {
        //create an instance of the flight book
        clsFlightCollection FlightBook = new clsFlightCollection();

        //find the record to update
        FlightBook.ThisFlight.Find(FlightID);
        //display the data for this record
        txtDateOfBirth.Text   = FlightBook.ThisFlight.DateOfBirth;
        txtGate.Text          = FlightBook.ThisFlight.Gate;
        txtDepartureDate.Text = FlightBook.ThisFlight.DepartureDate.ToString();
    }
        public void FilterByDestinationMethodOK()
        {
            //create an instance of the class containing unfiltred results
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create an instance of the filtered data
            clsFlightCollection FilteredFlights = new clsFlightCollection();

            //apply a blank string (should return all records);
            FilteredFlights.FilterByDestination("");
            //test to see that the two values are the same
            Assert.AreEqual(AllFlights.Count, FilteredFlights.Count);
        }
Esempio n. 22
0
        public void ReportByDateOfBirthMethod()
        {
            //create an instance of the class containing unfiltered results
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create an instance of the filtered data
            clsFlightCollection FilteredFlight = new clsFlightCollection();

            //apply a blank string (should return all records)
            FilteredFlight.ReportByDateOfBirth("");
            //test to see that the two values are the same
            Assert.AreEqual(AllFlight.Count, FilteredFlight.Count);
        }
    void DisplayBookings()
    {
        //create an instance of the booking collection
        clsFlightCollection Bookings = new clsFlightCollection();

        //set the data source to the list of bookings in the collection
        lstFlights.DataSource = Bookings.FlightList;
        //set the name of the primary key
        lstFlights.DataValueField = "FlightID";
        //set the data field to display
        lstFlights.DataTextField = "FlightNo";
        //bind the data to the list
        lstFlights.DataBind();
    }
        Int32 DisplayBookings()
        {
            //create an instance of the booking collection
            clsFlightCollection Bookings = new clsFlightCollection();

            //set the data source to the list of bookings in the collection
            lstFlights.DataSource = Bookings.FlightList;
            //set the name of the primary key
            lstFlights.ValueMember = "FlightID";
            //set the data field to display
            lstFlights.DisplayMember = "FlightNo";
            //bind the data to the list
            return(Bookings.Count);
        }
    void FilterByDestination(string Destination)
    {
        //create an instance of the booking collection
        clsFlightCollection C = new clsFlightCollection();

        C.FilterByDestination(Destination);
        //set the data source to the list of bookings in the collection
        lstFlights.DataSource = C.FlightList;
        //set the name of the primary key
        lstFlights.DataValueField = "FlightID";
        //set the data field to display
        lstFlights.DataTextField = "Destination";
        //bind the data to the list
        lstFlights.DataBind();
    }
        Int32 FilterByDestination(string Destination)
        {
            //create an instance of the booking collection
            clsFlightCollection C = new clsFlightCollection();

            C.FilterByDestination(Destination);
            //set the data source to the list of bookings in the collection
            lstFlights.DataSource = C.FlightList;
            //set the name of the primary key
            lstFlights.ValueMember = "FlightID";
            //set the data field to display
            lstFlights.DisplayMember = "Destination";
            //bind the data to the list
            return(C.Count);
        }
Esempio n. 27
0
        public void ThisFlightProperty()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create some test data to assign to the property
            clsFlight TestFlight = new clsFlight();

            TestFlight.FlightID      = 1;
            TestFlight.TicketID      = 2;
            TestFlight.DateOfBirth   = "1st May 2000";
            TestFlight.Gate          = "12B";
            TestFlight.DepartureDate = DateTime.Now.Date;
            //assign the data to the property
            AllFlight.ThisFlight = TestFlight;
            //test to see that the two value are the same
            Assert.AreEqual(AllFlight.ThisFlight, TestFlight);
        }
        public void ThisFlightsPropertyOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create some test data to assign to the property
            clsFlights TestFlights = new clsFlights();

            //set the properties of the test object
            TestFlights.FlightID         = 1;
            TestFlights.FlightNo         = "A114";
            TestFlights.Airline          = "Air India";
            TestFlights.ArrivalAirport   = "BHX";
            TestFlights.Arrival          = DateTime.Now.Date;
            TestFlights.Departure        = DateTime.Now.Date;
            TestFlights.DepartureAirport = "BHX";
            TestFlights.Destination      = "India";
            //assign the data to the property
            AllFlights.ThisFlight = TestFlights;
            //test to see that the two values are the same
            Assert.AreEqual(AllFlights.ThisFlight, TestFlights);
        }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsFlightCollection AllFlights = new clsFlightCollection();
            //create the item of test data
            clsFlights TestItem = new clsFlights();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.FlightNo         = "AA11";
            TestItem.Airline          = "Air India";
            TestItem.ArrivalAirport   = "DXB";
            TestItem.Arrival          = DateTime.Now.Date;
            TestItem.Departure        = DateTime.Now.Date;
            TestItem.DepartureAirport = "MCR";
            TestItem.Destination      = "Dubai";
            //set ThisFlights to the test data
            AllFlights.ThisFlight = TestItem;
            //add the record
            PrimaryKey = AllFlights.Add();
            //set the primary key of the test data
            TestItem.FlightID = PrimaryKey;
            //modify the test data
            TestItem.FlightNo         = "AA30";
            TestItem.Airline          = "Air France";
            TestItem.ArrivalAirport   = "LHR";
            TestItem.Arrival          = DateTime.Now.Date;
            TestItem.Departure        = DateTime.Now.Date;
            TestItem.DepartureAirport = "DHL";
            TestItem.Destination      = "Germany";
            //set the record based on the new test data
            AllFlights.ThisFlight = TestItem;
            //update the record
            AllFlights.Update();
            //find the record
            AllFlights.ThisFlight.Find(PrimaryKey);
            //test to see ThisFlights matches the test data
            Assert.AreEqual(AllFlights.ThisFlight, TestItem);
        }
Esempio n. 30
0
        public void ListAndCount()
        {
            //create an instance of a class
            clsFlightCollection AllFlight = new clsFlightCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsFlight> TestList = new List <clsFlight>();
            //add an item to the list
            //create the item of test data
            clsFlight TestItem = new clsFlight();

            //set its properties
            TestItem.FlightID      = 1;
            TestItem.TicketID      = 2;
            TestItem.DateOfBirth   = "1st May 2000";
            TestItem.Gate          = "12B";
            TestItem.DepartureDate = DateTime.Now.Date;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllFlight.FlightList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllFlight.Count, TestList.Count);
        }