Int32 DisplayOrder(string ItemTypeFilter) { Int32 OrderID; //var to store the primary key string ItemName; //var to store the item name string ItemType; // var to store the ItemType clsOrderCollection MyOrderCollection = new clsOrderCollection(); //create an instance of the Order collection class MyOrderCollection.ReportByItemType(ItemTypeFilter); //create an instance of the Order collection class Int32 RecordCount; //var to store the count of records Int32 Index = 0; //var to store the index for the loop RecordCount = MyOrderCollection.Count; //get the count of records lstOrder.Items.Clear(); //clear the list box while (Index < RecordCount) //while there are records to process { OrderID = MyOrderCollection.OrderList[Index].OrderID; //get the primary key ItemName = MyOrderCollection.OrderList[Index].ItemName; // get the ItemName ItemType = MyOrderCollection.OrderList[Index].ItemType; //get the ItemType //create a new entry for the list box ListItem NewEntry = new ListItem(ItemName + " , " + ItemType, OrderID.ToString()); lstOrder.Items.Add(NewEntry); //add the Order to the list Index++; //move the index to the next record } return(RecordCount); // return the count of records found }
public void ReportByMethodTestDataFound() { //create an instance of the filtered data clsOrderCollection FilteredItemType = new clsOrderCollection(); //var to store outcomes Boolean OK = true; //apply a Item type that doesn't exist FilteredItemType.ReportByItemType("121321313212132132131321"); //check that the correct number of records are found if (FilteredItemType.Count == 2) { //check that the first record is id 2 if (FilteredItemType.OrderList[0].OrderID != 9) { OK = false; } //check that the first record is id 1 if (FilteredItemType.OrderList[1].OrderID != 10) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsFalse(OK); }
public void ReportByItemNameNoneFound() { //create an instance of the filtered data clsOrderCollection FilteredItemType = new clsOrderCollection(); //apply a ItemType that doesn't exist FilteredItemType.ReportByItemType("xxxxx xxxxxxxxxx xxxx"); //test to see that there are no records Assert.AreEqual(0, FilteredItemType.Count); }
public void ReportByItemNameMethodOK() { // create an instance of the class clsOrderCollection AllOrder = new clsOrderCollection(); //create an instance of the filtered data clsOrderCollection FilteredItemType = new clsOrderCollection(); //apply a blank string (should return all records) FilteredItemType.ReportByItemType(""); //test to see that the two values are the same Assert.AreEqual(AllOrder.Count, FilteredItemType.Count); }