Esempio n. 1
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. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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;
            }
        }
    //function for adding new records
    void Add()
    {
        //create an instance of the flight 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);
            //add the record
            FlightBook.Add();
            //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 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);
        }
        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 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);
        }