コード例 #1
0
        public void ReportBySurnameTestDataFound()
        {
            // Create an instance of the filtered data
            clsCustomerCollection FilteredSurnames = new clsCustomerCollection();
            // Var to store the outcome
            Boolean OK = true;

            // Apply a Surname that doesn't exist
            FilteredSurnames.ReportBySurname("Jefferson");
            // Check that the correct number of records are found
            if (FilteredSurnames.Count == 2)
            {
                // Check that the first record id is 1020
                if (FilteredSurnames.CustomerList[0].CustomerID != 1024)
                {
                    OK = false;
                }
                // Check that the first record is ID 1021
                if (FilteredSurnames.CustomerList[1].CustomerID != 1025)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            // Test to see that there are no records
            Assert.IsTrue(OK);
        }
コード例 #2
0
        public void ReportBySurnameNoneFound()
        {
            // Create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            // Apply a surname that doesn't exist
            FilteredCustomers.ReportBySurname("XYZ");
            // Test to see that there are no records
            Assert.AreEqual(0, FilteredCustomers.Count);
        }
コード例 #3
0
        public void ReportBySurname()
        {
            // 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.ReportBySurname("");
            // Test to see that the two values are the same
            Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count);
        }
コード例 #4
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        // Create an instance of the customer collection
        clsCustomerCollection Customers = new clsCustomerCollection();

        Customers.ReportBySurname(txtFilter.Text);
        lstCustomerList.DataSource = Customers.CustomerList;
        // Set the name of the primary key
        lstCustomerList.DataValueField = "CustomerID";
        lstCustomerList.DataTextField  = "Surname";
        // bind the data to the list
        lstCustomerList.DataBind();
    }
コード例 #5
0
    protected void btnClear_Click(object sender, EventArgs e)
    {
        // Create an instance of the customer collection
        clsCustomerCollection Customers = new clsCustomerCollection();

        Customers.ReportBySurname("");
        // Clear any existing filter to tidy up the interface
        txtFilter.Text             = "";
        lstCustomerList.DataSource = Customers.CustomerList;
        // Set the name of the primary key
        lstCustomerList.DataValueField = "CustomerID";
        // set the name of the field to display
        lstCustomerList.DataTextField = "Surname";
        // Bind the data to the list
        lstCustomerList.DataBind();
    }