예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }
예제 #5
0
    // function to populate the list box
    Int32 DisplayDestinations(string DestinationFilter)
    {
        // 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 destination ID
        string DestinationID;
        // var for Index
        Int32 Index = 0;

        // clear the list of any existing item
        lstDestinations.Items.Clear();
        // call the filter method by destination name
        Destinations.FilterByDestination(DestinationFilter);
        // 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 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, DestinationID);
            // add the item to the list
            lstDestinations.Items.Add(NewItem);
            // increment the index
            Index++;
        }
        // return the number of records found
        return(RecordCount);
    }