예제 #1
0
        public void AddMethod()
        {
            //create an instance of a class
            clsLocationCollection AllLocation = new clsLocationCollection();
            //create the item of test data
            clsLocation TestItem = new clsLocation();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.LocationID         = 1;
            TestItem.PlaneID            = 2;
            TestItem.CountryDeparture   = "Bulgaria";
            TestItem.CountryDestination = "Africa";
            TestItem.AirportDeparture   = "Heathrow";
            TestItem.AirportDestination = "Gatwick";
            //set this location to the test data
            AllLocation.ThisLocation = TestItem;
            //add the record
            PrimaryKey = AllLocation.Add();
            //set the primary key of the test data
            TestItem.LocationID = PrimaryKey;
            //find the record
            AllLocation.ThisLocation.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllLocation.ThisLocation, TestItem);
        }
예제 #2
0
        public void DeleteMethod()
        {
            //create an instance of a class
            clsLocationCollection AllLocation = new clsLocationCollection();
            //create the item of test data
            clsLocation TestItem = new clsLocation();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.LocationID         = 1;
            TestItem.PlaneID            = 2;
            TestItem.CountryDeparture   = "Bulgaria";
            TestItem.CountryDestination = "Africa";
            TestItem.AirportDeparture   = "Heathrow";
            TestItem.AirportDestination = "Gatwick";
            //set this location to the test data
            AllLocation.ThisLocation = TestItem;
            //add the record
            PrimaryKey = AllLocation.Add();
            //set the primary key of the test data
            TestItem.LocationID = PrimaryKey;
            //find the record
            AllLocation.ThisLocation.Find(PrimaryKey);
            //delete the record
            AllLocation.Delete();
            //now find the record
            Boolean Found = AllLocation.ThisLocation.Find(PrimaryKey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
예제 #3
0
        public void ListAndCount()
        {
            //create an instance of a class
            clsLocationCollection AllLocation = new clsLocationCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsLocation> TestList = new List <clsLocation>();
            //add an item to the list
            //create the item of test data
            clsLocation TestItem = new clsLocation();

            //set its properties
            TestItem.LocationID         = 1;
            TestItem.PlaneID            = 2;
            TestItem.CountryDeparture   = "Bulgaria";
            TestItem.CountryDestination = "Africa";
            TestItem.AirportDeparture   = "Heathrow";
            TestItem.AirportDestination = "Gatwick";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllLocation.LocationList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllLocation.Count, TestList.Count);
        }
예제 #4
0
        public void InstanceOK()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();

            //test to see that it exists
            Assert.IsNotNull(ALocation);
        }
예제 #5
0
        //used to test the valid method of the class
        public void ValidMethod()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create a string variable to store the result of the validation
            string Error = "";

            //create some test data to test the method
            Error = ALocation.Valid(SomeCountryDeparture, SomeCountryDestination, SomeAirportDeparture, SomeAirportDestination);
            //test to see the result is ok. i.e there was no error mssage returned
            Assert.AreEqual(Error, "");
        }
예제 #6
0
        //used to test the Airport Destination property of the class
        public void AirportDestination()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create some test data to assign to the property
            string SomeAirportDestination = "Islamabad";

            //assign the data to the property
            ALocation.AirportDestination = SomeAirportDestination;
            //test to see that the two values are the same
            Assert.AreEqual(ALocation.AirportDestination, SomeAirportDestination);
        }
예제 #7
0
        //used to test the Country Destination property of the class
        public void CountryDestination()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create some test data to assign to the property
            string SomeCountryDestination = "Dubai";

            //assign the data to the property
            ALocation.CountryDestination = SomeCountryDestination;
            //test to see that the two values are the same
            Assert.AreEqual(ALocation.CountryDestination, SomeCountryDestination);
        }
예제 #8
0
        //used to test the Airport Departure property of the class
        public void AirportDeparture()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create some test data to assign to the property
            string SomeAirportDeparture = "Heathrow";

            //assign the data to the property
            ALocation.AirportDeparture = SomeAirportDeparture;
            //test to see that the two values are the same
            Assert.AreEqual(ALocation.AirportDeparture, SomeAirportDeparture);
        }
예제 #9
0
        //used to test the Location ID property of the class
        public void LocationID()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create some test data to assign to the property
            Int32 LocationID = 1;

            //assign the data to the property
            ALocation.LocationID = LocationID;
            //test to see that the two values are the same
            Assert.AreEqual(ALocation.LocationID, LocationID);
        }
예제 #10
0
        public void AirportDestinationMaxPlusOne()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create a string variable to store the result of the validation
            string Error = "";
            //create some test data to test the method
            string SomeAirportDestination = "abcndefghijklmnopqrstuvwyzabcdefgdsasdfgh";

            //invoke the method
            Error = ALocation.Valid(SomeCountryDeparture, SomeCountryDestination, SomeAirportDeparture, SomeAirportDestination);
            //Test to see that the result is not ok. i.e there should be an error message
            Assert.AreNotEqual(Error, "");
        }
예제 #11
0
        public void CountryDepartureMinLessOne()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create a string variable to store the result of the validation
            string Error = "";
            //create some test data to test the method
            string SomeCountryDeparture = "Alban";

            //invoke the method
            Error = ALocation.Valid(SomeCountryDeparture, SomeCountryDestination, SomeAirportDeparture, SomeAirportDestination);
            //Test to see that the result is not ok. i.e there should be an error message
            Assert.AreNotEqual(Error, "");
        }
예제 #12
0
        //used to test the find method of the class
        public void FindMethod()
        {
            //create an instance of the class
            clsLocation ALocation = new clsLocation();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to use with the method
            Int32 LocationID = 14;

            //invoke the method
            Found = ALocation.Find(LocationID);
            //test to see that the result is correct
            Assert.IsTrue(Found);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        //create an instance of clsLocation
        clsLocation ALocation = new clsLocation();

        //get the data from the session object
        ALocation = (clsLocation)Session["ALocation"];
        //display the country departure for this entry
        Response.Write(ALocation.CountryDeparture);
        //display the country destination for this entry
        Response.Write(ALocation.AirportDestination);
        //display the airport departure for this entry
        Response.Write(ALocation.AirportDeparture);
        //display the airport destination for this entry
        Response.Write(ALocation.AirportDestination);
    }
예제 #14
0
        public void AirportDestinationExtremeMax()
        {
            //create an instance of a class
            clsLocation ALocation = new clsLocation();
            //create a string variable to store the result of the validation
            string Error = "";
            //create some test data to test the method
            string SomeAirportDestination = "";

            //pad the string with characters
            SomeAirportDestination = SomeAirportDestination.PadRight(60, 'a');
            //invoke the method
            Error = ALocation.Valid(SomeCountryDeparture, SomeCountryDestination, SomeAirportDeparture, SomeAirportDestination);
            //Test to see that the result is not ok. i.e there should be an error message
            Assert.AreNotEqual(Error, "");
        }
예제 #15
0
        private void FillLocation()
        {
            clsLocation           e  = new clsLocation();
            clsLocationController ec = new clsLocationController();
            DataTable             dt = new DataTable();

            dt = ec.FetchAllLocation(currentUser.Username, "", "");
            if (dt.Rows.Count > 0)
            {
                ddlLocation.DataSource     = dt;
                ddlLocation.DataTextField  = "Loc_LocationName";
                ddlLocation.DataValueField = "Loc_LocationID";
                ddlLocation.DataBind();
                ddlLocation.Items.Insert(0, new ListItem("-- Select --", "0"));
            }
        }
예제 #16
0
        public void ThisLocationProperty()
        {
            //create an instance of a class
            clsLocationCollection AllLocation = new clsLocationCollection();
            //create some test data to assign to the property
            clsLocation TestLocation = new clsLocation();

            //set the properties of the test object
            TestLocation.LocationID         = 1;
            TestLocation.PlaneID            = 2;
            TestLocation.CountryDeparture   = "Bulgaria";
            TestLocation.CountryDestination = "Africa";
            TestLocation.AirportDeparture   = "Heathrow";
            TestLocation.AirportDestination = "Gatwick";
            //assign the data to the property
            AllLocation.ThisLocation = TestLocation;
            //test to see that the two values are the same
            Assert.AreEqual(AllLocation.ThisLocation, TestLocation);
        }
예제 #17
0
        public void TestPlaneIDFound()
        {
            //create an instance of the class
            clsLocation ALocation = new clsLocation();
            //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 LocationID = 14;

            //imvoke the method
            Found = ALocation.Find(LocationID);
            //check the plane id
            if (ALocation.PlaneID != 1)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }
예제 #18
0
        public void UpdateMethod()
        {
            //create an instance of a class
            clsLocationCollection AllLocation = new clsLocationCollection();
            //create the item of test data
            clsLocation TestItem = new clsLocation();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.PlaneID            = 2;
            TestItem.CountryDeparture   = "Bulgaria";
            TestItem.CountryDestination = "Africa";
            TestItem.AirportDeparture   = "Heathrow";
            TestItem.AirportDestination = "Gatwick";
            //set this location to the test data
            AllLocation.ThisLocation = TestItem;
            //add the record
            PrimaryKey = AllLocation.Add();
            //set the primary key of the test data
            TestItem.LocationID = PrimaryKey;
            //modify the test data
            TestItem.PlaneID            = 3;
            TestItem.CountryDeparture   = "Belgium";
            TestItem.CountryDestination = "Zimbabwe";
            TestItem.AirportDeparture   = "Lahore";
            TestItem.AirportDestination = "Heathrow";
            //set the record based on the new test data
            AllLocation.ThisLocation = TestItem;
            //update the record
            AllLocation.Update();
            //find the record
            AllLocation.ThisLocation.Find(PrimaryKey);
            //test to see thislocation matches the test data
            Assert.AreEqual(AllLocation.ThisLocation, TestItem);
        }