Int32 DisplayPhone(string MakeFilter) { Int32 PhoneID; //Var to store the primary key String Make; //Var to store the Make String Model; //Var to store the Model clsPhoneCollection MakeSearch = new clsPhoneCollection(); //Create an instance of the phone book class MakeSearch.ReportByMake(MakeFilter); //invoke the phone make filter Int32 RecordCount; //Var to store the count of records Int32 Index = 0; //Var to store the index for the loop RecordCount = MakeSearch.Count; //get the count of records lstPhones.Items.Clear(); //clear the list box while (Index < RecordCount) //While there are records to process { PhoneID = MakeSearch.PhoneList[Index].PhoneID; //get primary key Make = MakeSearch.PhoneList[Index].Make; //get Make Model = MakeSearch.PhoneList[Index].Model; //get Model //create a new entry for the list box ListItem NewEntry = new ListItem(Make + " " + Model, PhoneID.ToString()); lstPhones.Items.Add(NewEntry); Index++; } return(RecordCount); //return the count of records found }
public void ReportByMakeTestDataFound() //Report By Make Test Data Found Method { //create an instance of the filtered data clsPhoneCollection FilteredPhones = new clsPhoneCollection(); //var to store outcome Boolean OK = true; //apply a make that does exist FilteredPhones.ReportByMake("Nokia"); //check that the correct number of records are found if (FilteredPhones.Count == 2) { //check that the first record id ID 36 if (FilteredPhones.PhoneList[0].PhoneID != 7) { OK = false; } //check that the first record is ID 37 if (FilteredPhones.PhoneList[1].PhoneID != 8) { OK = false; } } else { OK = false; } //test to see that the two values are the same Assert.IsTrue(OK); }
public void ReportByMakeNoneFound() //Report By Make None Found Method { //create an instance of the filtered data clsPhoneCollection FilteredPhones = new clsPhoneCollection(); //apply a blank string (Should return all phones) FilteredPhones.ReportByMake(" xxxx"); //test to see that the two values are the same Assert.AreEqual(0, FilteredPhones.Count); }
public void ReportByMakeMethodOK() //Report By Make Method { //create an instance of the class containing unfiltered results clsPhoneCollection AllPhones = new clsPhoneCollection(); //create an instance of the filtered data clsPhoneCollection FilteredPhones = new clsPhoneCollection(); //apply a blank string (Should return all phones) FilteredPhones.ReportByMake(""); //test to see that the two values are the same Assert.AreEqual(AllPhones.Count, FilteredPhones.Count); }