public void ReportBySurNameTestDataFound() { //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.ReportBySurName("xxxxx"); //check that the correct number of records are found if (FilteredCustomers.Count == 2) { //check that the first record is ID 36 if (FilteredCustomers.CustomerList[0].CustomerID != 36) { OK = false; } //check that the first record is ID 37 if (FilteredCustomers.CustomerList[1].CustomerID != 37) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void ReportBySurNameNoneFound() { //create an instance of the filtered data clsCustomerCollection FilteredCustomers = new clsCustomerCollection(); //apply a surname that doesn't exist FilteredCustomers.ReportBySurName("xxxxx"); //test to see that the two values are the same Assert.AreEqual(0, FilteredCustomers.Count); }
public void ReportBySurNameOK() { //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); }
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"; //set the name of the field to display lstCustomerList.DataTextField = "SurName"; //bind the data to the list lstCustomerList.DataBind(); }
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(); }