public void ReportByPostcodeTestDataFound() { //create an instance of the filtered data clsCustomerCollection FilteredPostcodes = new clsCustomerCollection(); //var to store the outcome Boolean OK = true; //apply a postcode that does exist FilteredPostcodes.ReportByPostcode("LE1 6MN"); //check that the correct number of records are found if (FilteredPostcodes.Count == 2) { //check that the first record is ID 1 if (FilteredPostcodes.CustomerList[0].CustomerID != 1) { OK = false; } //check that the first record is ID 2 if (FilteredPostcodes.CustomerList[1].CustomerID != 2) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void ReportByPostcodeNoneFound() { //create an instance of the clsCustomerCollection class clsCustomerCollection FilteredPostcodes = new clsCustomerCollection(); //apply a postcode that doesnt exist FilteredPostcodes.ReportByPostcode("xxx xxx"); //test to see that the two values are the same Assert.AreEqual(0, FilteredPostcodes.Count); }
public void ReportByPostcodeMethodOK() { //create an instance of the clsCustomerCollection class clsCustomerCollection AllCustomers = new clsCustomerCollection(); // create an instance of the filtered data clsCustomerCollection FilteredPostcodes = new clsCustomerCollection(); //apply a blank string (should return all records) FilteredPostcodes.ReportByPostcode(""); //test to see that the two values are the same Assert.AreEqual(AllCustomers.Count, FilteredPostcodes.Count); }
Int32 DisplayPostcode(string PostcodeFilter) { Int32 CustomerID; string Customerpostcode; string Customerfirstname; //create an instance of the Shoes Collection clsCustomerCollection CustomerPostcode = new clsCustomerCollection(); //invoke the shoe brand filter CustomerPostcode.ReportByPostcode(PostcodeFilter); //var to store the count of records Int32 RecordCount; //var to store the index for the loop Int32 Index = 0; //get the count of records RecordCount = CustomerPostcode.Count; //clear the list box lstCustomers.Items.Clear(); //while there are records to process while (Index < RecordCount) { //get the primary key CustomerID = CustomerPostcode.CustomerList[Index].CustomerID; //get the shoe name Customerpostcode = CustomerPostcode.CustomerList[Index].Customerpostcode; Customerfirstname = CustomerPostcode.CustomerList[Index].Customerfirstname; //create a new entry for the list box ListItem NewEntry = new ListItem(Customerpostcode + " " + Customerfirstname, CustomerID.ToString()); //add the shoes to the list lstCustomers.Items.Add(NewEntry); //move the index to the next record Index++; } return(RecordCount); }