Example #1
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);
        }
Example #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);
        }
Example #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);
        }
        public void InstanceOK()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();

            //test to see that it exists
            Assert.IsNotNull(AFlight);
        }
        //used to test the departure date property of the class
        public void DepartureDate()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create some test data to assign to the property
            DateTime SomeDepartureDate = DateTime.Now.Date;

            //assign the data to the property
            AFlight.DepartureDate = SomeDepartureDate;
            //test to see that the two values are the same
            Assert.AreEqual(AFlight.DepartureDate, SomeDepartureDate);
        }
        //used to test the ticket ID foreign key property of the class
        public void TicketID()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create some test data to assign to the property
            Int32 TicketID = 1;

            //assign the data to the property
            AFlight.TicketID = TicketID;
            //test to see that the two values are the same
            Assert.AreEqual(AFlight.TicketID, TicketID);
        }
        //used to test the valid method of the class
        public void ValidMethod()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create a string variable to store the result of the validation
            string Error = "";

            //create some test data to test the method
            Error = AFlight.Valid(SomeDateOfBirth, SomeGate, SomeDepartureDate);
            //test to see the result is ok. i.e there was no error mssage returned
            Assert.AreEqual(Error, "");
        }
        //used to test the gate property of the class
        public void Gate()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create some test data to assign to the property
            string SomeGate = "12B";

            //assign the data to the property
            AFlight.Gate = SomeGate;
            //test to see that the two values are the same
            Assert.AreEqual(AFlight.Gate, SomeGate);
        }
        //used to test the date of birth property of the class
        public void DateOfBirth()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create some test data to assign to the property
            string SomeDateOfBirth = "1st April 1999";

            //assign the data to the property
            AFlight.DateOfBirth = SomeDateOfBirth;
            //test to see that the two values are the same
            Assert.AreEqual(AFlight.DateOfBirth, SomeDateOfBirth);
        }
        public void DepartureDateInvalidData()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();            //string variable to store any error message
            string    Error   = "";
            //set the date to a non date value
            string SomeDepartureDate = "This is not a date!";

            //invoke the method
            Error = AFlight.Valid(SomeDateOfBirth, SomeGate, SomeDepartureDate);            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //create an instance of a class
        clsFlight AFlight = new clsFlight();

        //get the data from the session object
        AFlight = (clsFlight)Session["AFlight"];
        //display the date of birth for this entry
        Response.Write(AFlight.DateOfBirth);
        //display the gate
        Response.Write(AFlight.Gate);
        //display the departure date
        Response.Write(AFlight.DepartureDate);
    }
Example #12
0
        //used to test the flight find method of the class
        public void FindMethod()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to use with the method
            Int32 FlightID = 26;

            //invoke the method
            Found = AFlight.Find(FlightID);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
        public void GatehMaxPlusOne()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create a string variable to store the result of the validation
            string Error = "";
            //create some test data to test the method
            string SomeGate = "123ASD";

            //invoke the method
            Error = AFlight.Valid(SomeDateOfBirth, SomeGate, SomeDepartureDate);
            //Test to see that the result is not ok. i.e there should be an error message
            Assert.AreNotEqual(Error, "");
        }
        public void GateExtremeMax()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //create a string variable to store the result of the validation
            string Error = "";
            //create some test data to test the method
            string SomeGate = "";

            //pad the string with characters
            SomeGate = SomeGate.PadRight(20, 'a');
            //invoke the method
            Error = AFlight.Valid(SomeDateOfBirth, SomeGate, SomeDepartureDate);
            //Test to see that the result is not ok. i.e there should be an error message
            Assert.AreNotEqual(Error, "");
        }
Example #15
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 DepartureDateExtremeMax()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //string variable to store any error message
            string Error = "";
            //create a variable to store the booking date data  //set the date to todays date
            DateTime TestDate = DateTime.Now.Date;

            //change the date to whatever the date is plus 100 years
            TestDate = TestDate.AddYears(100);
            //convert the date variable to a string variable
            string SomeDepartureDate = TestDate.ToString();

            //invoke the method
            Error = AFlight.Valid(SomeDateOfBirth, SomeGate, SomeDepartureDate);
            //test to see that the result is correct
            Assert.AreNotEqual(Error, "");
        }
Example #17
0
        //used to test the TicketID property of the class
        public void TestTicketIDFound()
        {
            //create an instance of a class
            clsFlight AFlight = new clsFlight();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is ok
            Boolean OK = true;
            //create some test data to use with the method
            Int32 FlightID = 26;

            //invoke the method
            Found = AFlight.Find(FlightID);
            //check the StaffID
            if (AFlight.TicketID != 10)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
Example #18
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);
        }