public void ReportByBookDescriptionTestDataFound() { //create an instance of the filtered data clsStockCollection FilteredStock = new clsStockCollection(); //var to store outcome Boolean OK = true; //apply a Book Decription that doesnt exist FilteredStock.ReportByBookDescription("TestBook"); //check that the correct number of records are found if (FilteredStock.Count == 2) { //check that the first record is ID 21 if (FilteredStock.StockList[0].BookId != 21) { OK = false; } //check that the first record is Id 36 if (FilteredStock.StockList[1].BookId != 22) { OK = false; } } else { OK = false; } //test to see that there are no records Assert.IsTrue(OK); }
public void ReportByBookDescriptionNoneFound() { //create an instance of the filtered data clsStockCollection FilteredStock = new clsStockCollection(); //apply a BookDescription that doesnt exist FilteredStock.ReportByBookDescription("people "); //test to see that ther are no records found Assert.AreEqual(0, FilteredStock.Count); }
public void ReportByBookDescriptionMethodOk() { //create an instance of the class containing unfiltered results clsStockCollection AllStock = new clsStockCollection(); //create an instance of the filtered data clsStockCollection FilteredStock = new clsStockCollection(); //apply a blank string FilteredStock.ReportByBookDescription(""); //test to see that the two values are the same Assert.AreEqual(AllStock.Count, FilteredStock.Count); }
protected void btnApply_Click(object sender, EventArgs e) { //create an instance of the stock collection clsStockCollection Stock = new clsStockCollection(); Stock.ReportByBookDescription(txtFilter.Text); lstStockList.DataSource = Stock.StockList; //set the name of the primary key lstStockList.DataValueField = "BookId"; //set the name of the fiels to display lstStockList.DataTextField = "Description"; //bind the data to the list lstStockList.DataBind(); }
protected void btnClear_Click(object sender, EventArgs e) { //create an instance of the stock collection clsStockCollection Stock = new clsStockCollection(); Stock.ReportByBookDescription(""); //clear any existing filter to tidy up the interface txtFilter.Text = ""; lstStockList.DataSource = Stock.StockList; //set the name of the primary key lstStockList.DataValueField = "BookId"; //set the name of the field display lstStockList.DataTextField = "Decription"; //bind the data tot he list lstStockList.DataBind(); }