Ejemplo n.º 1
0
        public void FilterBySurnameTestDataFound()
        {
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a surname that doesn't exist
            FilteredCustomers.FilterBySurname("ggg ggg");
            //check that the correct number of records are found
            if (FilteredCustomers.Count == 2)
            {
                //check that the first record is ID 3
                if (FilteredCustomers.CustomerList[0].CustomerNo != 1)
                {
                    OK = false;
                }
                //check that the first record is ID 4
                if (FilteredCustomers.CustomerList[1].CustomerNo != 2)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
Ejemplo n.º 2
0
        public void FilterBySurnameNoneFound()
        {
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            //apply a post code that doesn't exist
            FilteredCustomers.FilterBySurname("a");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredCustomers.Count);
        }
Ejemplo n.º 3
0
        public void FilterBySurnameMethodOK()
        {
            //create an instance of the class containing unfiltered results
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            //apply a blank string (should return all records);
            FilteredCustomers.FilterBySurname("");
            //test to see that the two values are the same
            Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count);
        }
Ejemplo n.º 4
0
    // function to populate the list box
    Int32 Displaycustomers(string CustomerFilter)
    {
        // create an instance of the staff collection class
        clsCustomerCollection Customers = new clsCustomerCollection();
        // var for record count
        Int32 RecordCount;
        // var for last name
        string Surname;
        //string for Email
        string Email;
        // var for Customer ID
        string CustomerNo;
        // var for Index
        Int32 Index = 0;

        // clear the list of any existing item
        lstCustomers.Items.Clear();
        // call the filter method by customer last name
        Customers.FilterBySurname(CustomerFilter);
        // get the count of records
        RecordCount = Customers.Count;
        // loop through each record found using the index
        while (Index < RecordCount)
        {
            // get the last name of the customer
            Surname = Convert.ToString(Customers.CustomerList[Index].Surname);
            // get the email of the customer
            Email = Convert.ToString(Customers.CustomerList[Index].Email);
            // get the ID of the Customer
            CustomerNo = Convert.ToString(Customers.CustomerList[Index].CustomerNo);
            // set up a new object of class list item
            ListItem NewItem = new ListItem(Surname + "," + Email, CustomerNo);
            // add the item to the list
            lstCustomers.Items.Add(NewItem);
            // increment the index
            Index++;
        }
        // return the number of records found
        return(RecordCount);
    }