public void FilterByCustomerIDTestDataFound() { //create an instance of the filtered data clsCustomerCollection FilteredCustomer = new clsCustomerCollection(); //var to store outcome Boolean OK = true; //apply a last name that doesnt exist FilteredCustomer.FilterByCustomerID(2); //check that the correct number of records are found if (FilteredCustomer.Count == 2) { //check that the first record is ID 4 if (FilteredCustomer.CustomerList[0].CustomerID != 4) { OK = false; } //check that the first record is ID 2 if (FilteredCustomer.CustomerList[0].CustomerID != 2) { OK = false; } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); } }
public void FilterByCustomerIdNoneFound() { //create an instance of the filtered data clsCustomerCollection FilteredCustomer = new clsCustomerCollection(); //apply a blank string (should return all records); FilteredCustomer.FilterByCustomerID(0); //test to see that the two values are the same Assert.AreEqual(0, FilteredCustomer.Count); }
public void FilterByCustomerIdTestDataFound() { //create an instance of the filtered data clsCustomerCollection FilteredCustomer = new clsCustomerCollection(); //var to store outcome Boolean Ok = true; //apply a customer id that doesnt exist FilteredCustomer.FilterByCustomerID(12); //check that the correct number of records are found if (FilteredCustomer.Count < 1) { if (FilteredCustomer.mCustomerList[0].customerid != 12) { Ok = false; } } else { Ok = false; } //test to see that the two values are the same Assert.IsTrue(Ok); }
Int32 DisplayCustomer(int customerID) { ///this function accepts one parameter - the post code to filter the list on ///it populates the list box with data from the middle layer class ///it returns a single value, the number of records found //create a new instance of the clsCustomer clsCustomerCollection Customer = new clsCustomerCollection(); //var to store the count of records Int32 RecordCount; //var to stroe the name string name; //var to the address string Address; //car to store the ContactNumber string ContactNumber; //var to store the Postcode string PostCode; //var to store th email address string EmailAddress; //var to store the active bool Active; //var to store the customerid string CustomerID; Int32 Index = 0; //clear the lists of any existing items lstCustomer.Items.Clear(); //call the filer by CustomerID Customer.FilterByCustomerID(customerID); //get the counts of records found RecordCount = Customer.Count; ListItem NewItem1 = new ListItem("Name...." + "Address...." + "PostCode.... " + "Email...." + "ContactNumber.... " + "Active...." + "CustomerID...."); lstCustomer.Items.Add(NewItem1); //loop through each records found using the index point to each record in the data table while (Index < RecordCount) { //get the name from the query resutlos name = Convert.ToString(Customer.CustomerList[Index].Name); //get the address from the query resutlos Address = Convert.ToString(Customer.CustomerList[Index].Address); //get the post code from the query results PostCode = Convert.ToString(Customer.CustomerList[Index].PostCode); //get the emailaddress no from the query results EmailAddress = Convert.ToString(Customer.CustomerList[Index].EmailAddress); //get the address no from the query results CustomerID = Convert.ToString(Customer.CustomerList[Index].CustomerID); //get the contact number from the quesry results ContactNumber = Convert.ToString(Customer.CustomerList[Index].ContactNumber); //get the active from the quesry results Active = Convert.ToBoolean(Customer.CustomerList[Index].Active); //set up a new object of class list item ListItem NewItem = new ListItem("" + name + "...." + Address + "...." + PostCode + ".... " + EmailAddress + "...." + ContactNumber + "...." + Active + "....", CustomerID); //add the new item to the list lstCustomer.Items.Add(NewItem); //increment the index Index++; } //return the number of records found return(RecordCount); }