コード例 #1
0
        public void FilterByDestinationTestPKDataFound()
        {
            // create an instance of the filtered data
            clsDestinationCollection FilteredDestinations = new clsDestinationCollection();
            // var to store outcome
            Boolean OK = true;

            // apply a destination that does exist
            FilteredDestinations.FilterByDestination("California");
            // check that the correct number of records are found
            if (FilteredDestinations.Count == 2)
            {
                // check the first record is ID 8
                if (FilteredDestinations.DestinationList[0].DestinationID != 9)
                {
                    OK = false;
                }
                // check the first record if ID 11
                if (FilteredDestinations.DestinationList[1].DestinationID != 10)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            // test to see that there are no records
            Assert.IsTrue(OK);
        }
コード例 #2
0
        public void FilterByDestinationTestPriceDataFound()
        {
            // create an instance of the filtered data
            clsDestinationCollection FilteredDestinations = new clsDestinationCollection();
            // var to store outcome
            Boolean OK = true;

            // apply a destination that exists
            FilteredDestinations.FilterByDestination("California");
            // check that the correct number of records are found
            if (FilteredDestinations.Count == 2)
            {
                // check the data is 300
                if (FilteredDestinations.DestinationList[0].PricePerPerson != 300)
                {
                    OK = false;
                }
                // check the data is 250
                if (FilteredDestinations.DestinationList[1].PricePerPerson != 250)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            // test to see that there are no records
            Assert.IsTrue(OK);
        }
コード例 #3
0
        public void AddMethodOk()
        {
            // create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            // create the item of test data
            clsDestination TestItem = new clsDestination();
            // primary key variable
            Int32 PrimaryKey = 0;

            // set its properties
            TestItem.DestinationID  = 1;
            TestItem.Destination    = "Rome";
            TestItem.PricePerPerson = 99;
            TestItem.DayOfFlight    = DateTime.Now.Date;
            TestItem.ReturnDate     = DateTime.Now.Date.AddDays(1);
            // set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            // add the record
            PrimaryKey = AllDestinations.Add();
            // set the primary key of the test data
            TestItem.DestinationID = PrimaryKey;
            // find the record
            AllDestinations.ThisDestination.Find(PrimaryKey);
            // test to see that the two values are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
コード例 #4
0
        void Update()
        {
            clsDestinationCollection DestinationBook = new clsDestinationCollection();
            //validate the data on the web form
            String Error = DestinationBook.ThisDestination.Valid(txtHouseNo.Text, txtPostCode.Text, txtStreet.Text, txtTown.Text, txtPickUp.Text);

            //if the datas is OK the add it to the object
            if (Error == "")
            {
                //find the record to update
                DestinationBook.ThisDestination.Find(DestinationID);
                //get the data entered by the user
                DestinationBook.ThisDestination.EndPointHouseNo  = txtHouseNo.Text;
                DestinationBook.ThisDestination.EndPointPostCode = txtPostCode.Text;
                DestinationBook.ThisDestination.EndPointStreet   = txtStreet.Text;
                DestinationBook.ThisDestination.EndPointTown     = txtTown.Text;
                DestinationBook.ThisDestination.PickupTime       = Convert.ToDateTime(txtPickUp.Text);
                DestinationBook.ThisDestination.DropoffTime      = Convert.ToDateTime(txtPickUp.Text);
                //add the record
                DestinationBook.Update();
                Response.Redirect("DestinationPage.aspx");
            }
            else
            {
                //report an error
                lblError.Text = "There were problem with the data enetered " + Error;
            }
        }
コード例 #5
0
    // function for updating destinations
    void Update()
    {
        // create an instance of the destination collection class
        clsDestinationCollection Destinations = new clsDestinationCollection();
        // validate the data
        Boolean OK = Destinations.ThisDestination.Valid(txtDestinationName.Text, Convert.ToDecimal(txtPrice.Text), txtDayofFlight.Text, txtReturnDate.Text);

        // if the data is OK then add it to the object
        if (OK == true)
        {
            // find the record to update
            Destinations.ThisDestination.Find(DestinationID);
            // get the data entered by the user
            Destinations.ThisDestination.Destination    = txtDestinationName.Text;
            Destinations.ThisDestination.PricePerPerson = Convert.ToDecimal(txtPrice.Text);
            Destinations.ThisDestination.DayOfFlight    = Convert.ToDateTime(txtDayofFlight.Text);
            Destinations.ThisDestination.ReturnDate     = Convert.ToDateTime(txtReturnDate.Text);
            // update the record
            Destinations.Update();
        }
        else
        {
            // error
            lblError.Text = "There is a problem with the data entered";
        }
    }
コード例 #6
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to creat
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create the item of test data
            clsDestination TestItem = new clsDestination();
            //var to store the primary key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.DestinationID    = 1;
            TestItem.EndPointHouseNo  = "1";
            TestItem.EndPointPostCode = "LE2 2WX";
            TestItem.EndPointStreet   = "God Street";
            TestItem.EndPointTown     = "Leicester";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            //add the record
            Primarykey = AllDestinations.Add();
            //find the record
            AllDestinations.ThisDestination.Find(Primarykey);
            //test to see that the two valyes are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
コード例 #7
0
        public void ListAndCountOk()
        {
            //create an instance of the class we want to creat
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsDestination> TestList = new List <clsDestination>();
            //add an item to the list
            //create the item of test data
            clsDestination TestItem = new clsDestination();

            //set its properties
            TestItem.DestinationID    = 1;
            TestItem.EndPointHouseNo  = "1";
            TestItem.EndPointPostCode = "LE2 2WX";
            TestItem.EndPointStreet   = "God Street";
            TestItem.EndPointTown     = "Leicester";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the date to the property
            AllDestinations.DestinationList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllDestinations.Count, TestList.Count);
        }
コード例 #8
0
        public void InstanceOK()
        {
            // create an instance of the class we want to create
            clsDestinationCollection Destinations = new clsDestinationCollection();

            // test to see that it exists
            Assert.IsNotNull(Destinations);
        }
コード例 #9
0
        public void FilterByDestinationNoneFound()
        {
            // create an instance of the filtered data
            clsDestinationCollection FilteredDestinations = new clsDestinationCollection();

            // apply a destination that does not exist
            FilteredDestinations.FilterByDestination("XXX XXX");
            // test to see that there are no records
            Assert.AreEqual(0, FilteredDestinations.Count);
        }
コード例 #10
0
        void DeleteDestination()
        {
            //function to delete the select record
            //create a new instance of the Destination book
            clsDestinationCollection DestinationBook = new clsDestinationCollection();

            //find the record to delete
            DestinationBook.ThisDestination.Find(DestinationID);
            //Delete the record
            DestinationBook.Delete();
        }
コード例 #11
0
        public void FilterByDestinationMethodOK()
        {
            // create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            // create an instance of the filtered data
            clsDestinationCollection FilteredDestinations = new clsDestinationCollection();

            // apply a blank string to return all records
            FilteredDestinations.FilterByDestination("");
            // test to see that the two values are the same
            Assert.AreEqual(AllDestinations.Count, FilteredDestinations.Count);
        }
コード例 #12
0
    void DisplayDestination()
    {
        // create an instance of the destination collection class
        clsDestinationCollection Destinations = new clsDestinationCollection();

        // find the record to update
        Destinations.ThisDestination.Find(DestinationID);
        // display the data of the record chosen
        txtDestinationName.Text = Destinations.ThisDestination.Destination;
        txtPrice.Text           = Destinations.ThisDestination.PricePerPerson.ToString();
        txtDayofFlight.Text     = Destinations.ThisDestination.DayOfFlight.ToString();
        txtReturnDate.Text      = Destinations.ThisDestination.ReturnDate.ToString();
    }
コード例 #13
0
        void DisplayDestination()
        {
            clsDestinationCollection DestinationBook = new clsDestinationCollection();

            //find the record to update
            DestinationBook.ThisDestination.Find(DestinationID);
            //find the record to update
            txtHouseNo.Text  = DestinationBook.ThisDestination.EndPointHouseNo;
            txtPostCode.Text = DestinationBook.ThisDestination.EndPointPostCode;
            txtStreet.Text   = DestinationBook.ThisDestination.EndPointStreet;
            txtTown.Text     = DestinationBook.ThisDestination.EndPointTown;
            txtPickUp.Text   = DestinationBook.ThisDestination.PickupTime.ToString();
        }
コード例 #14
0
ファイル: MainMenu.aspx.cs プロジェクト: YF0204/DMUAirline
    // function to populate the list box - for display purposes only
    Int32 DisplayDestinations()
    {
        // create an instance of the destination collection
        clsDestinationCollection Destinations = new clsDestinationCollection();
        // var for record count
        Int32 RecordCount;
        // var for destination name
        string DestinationName;
        // var for destination price per person
        decimal DestinationPrice;
        // var for single flight
        string DayFlight;
        // var for return flight
        string ReturnFlight;
        // var for destination ID
        string DestinationID;
        // var for Index
        Int32 Index = 0;

        // clear the list of any existing item
        lstFlights.Items.Clear();
        // get the count of records
        RecordCount = Destinations.Count;
        // loop through each record found using the index
        while (Index < RecordCount)
        {
            // get the name of the destination
            DestinationName = Convert.ToString(Destinations.DestinationList[Index].Destination);
            // get the price per person for each destination
            DestinationPrice = Convert.ToDecimal(Destinations.DestinationList[Index].PricePerPerson);
            // get the day of flight
            DayFlight = Convert.ToString(Destinations.DestinationList[Index].DayOfFlight);
            // get the return flight
            ReturnFlight = Convert.ToString(Destinations.DestinationList[Index].ReturnDate);
            // get the ID of each destination
            DestinationID = Convert.ToString(Destinations.DestinationList[Index].DestinationID);
            // set up a new object of class list item
            ListItem NewItem = new ListItem(DestinationName + " " + "£PP" + " " + " " + DestinationPrice + " " + DayFlight + " " + ReturnFlight, DestinationID);
            // add the item to the list
            lstFlights.Items.Add(NewItem);
            // increment the index
            Index++;
        }
        // return the number of records found
        return(RecordCount);
    }
コード例 #15
0
        public void ThisDestinationPropertyOK()
        {
            // create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            // create some test data to assign to the property
            clsDestination TestDestination = new clsDestination();

            // set the properties to the test object
            TestDestination.DestinationID  = 1;
            TestDestination.Destination    = "Rome";
            TestDestination.PricePerPerson = 99;
            TestDestination.DayOfFlight    = DateTime.Now.Date;
            TestDestination.ReturnDate     = DateTime.Now.Date.AddDays(1);
            // assign the data to the property
            AllDestinations.ThisDestination = TestDestination;
            // test to see that the two values are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestDestination);
        }
コード例 #16
0
        Int32 DisplaysDestination()
        {
            //create an instance of the Destination collection
            clsDestinationCollection Destinations = new clsDestinationCollection();

            //find all destination
            Destinations.FindAllDestinations();
            //set the data source to the list of the destinations in the collection
            lstDestinations.DataSource = Destinations.DestinationList;
            //set the test to be displayed
            lstDestinations.DataTextField = "EndPointTown";
            //set the primary key
            lstDestinations.DataValueField = "DestinationID";
            //return the count of records in the list
            lstDestinations.DataBind();
            //bind the data to the list
            return(Destinations.DestinationList.Count);
        }
コード例 #17
0
        public void ThisDestinationPropertyOK()
        {
            //create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create some test data to assign to the property
            clsDestination TestDestination = new clsDestination();

            //set its properties
            TestDestination.DestinationID    = 1;
            TestDestination.EndPointHouseNo  = "1";
            TestDestination.EndPointPostCode = "LE2 2WX";
            TestDestination.EndPointStreet   = "God Street";
            TestDestination.EndPointTown     = "Leicester";
            TestDestination.PickupTime       = DateTime.Now.Date;
            TestDestination.DropoffTime      = DateTime.Now.Date;
            //assign the data to the property
            AllDestinations.ThisDestination = TestDestination;
            //test to see that the two values are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestDestination);
        }
コード例 #18
0
        public void ListAndCountOK()
        {
            // create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            // create a list of test data
            List <clsDestination> TestList = new List <clsDestination>();
            // create the item of test data
            clsDestination TestItem = new clsDestination();

            // set its properties
            TestItem.DestinationID  = 1;
            TestItem.Destination    = "Rome";
            TestItem.PricePerPerson = 99;
            TestItem.DayOfFlight    = DateTime.Now.Date;
            TestItem.ReturnDate     = DateTime.Now.Date.AddDays(1);
            // add the item to the test list
            TestList.Add(TestItem);
            // assign the data to the property
            AllDestinations.DestinationList = TestList;
            // test to see that the two values are the same
            Assert.AreEqual(AllDestinations.Count, TestList.Count);
        }
コード例 #19
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to creat
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create the item of test data
            clsDestination TestItem = new clsDestination();
            //var to store the primary key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.EndPointHouseNo  = "1";
            TestItem.EndPointPostCode = "LE2 2WX";
            TestItem.EndPointStreet   = "God Street";
            TestItem.EndPointTown     = "Leicester";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            //add the record
            Primarykey = AllDestinations.Add();
            //set the primary key of the test data
            TestItem.DestinationID = Primarykey;
            //modify the test data
            TestItem.EndPointHouseNo  = "132";
            TestItem.EndPointPostCode = "GH2 2WX";
            TestItem.EndPointStreet   = "God's Son Street";
            TestItem.EndPointTown     = "Ash Town";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set the record based on the new test data
            AllDestinations.ThisDestination = TestItem;
            //update the record
            AllDestinations.Update();
            //find the record
            AllDestinations.ThisDestination.Find(Primarykey);
            //test to see ThisDestionation match the test date
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }