public void TestDeleteMethod() { // create collection instance clsBrandCollection AllBrands = new clsBrandCollection(); // create the test brand clsBrand Brand = new clsBrand(); //PK Var Int32 PK = 0; //set brand's fields Brand.BrandName = "Nike"; Brand.TopProduct = 1; Brand.LatestProduct = 2; Brand.LastRestock = DateTime.Now.Date; Brand.AvgPrice = 0.00; // set the collection's thisbrand to the test item. AllBrands.ThisBrand = Brand; // add record to database PK = AllBrands.Add(); // set brand PK Brand.BrandID = PK; // find record AllBrands.ThisBrand.Find(PK); //invoke delete AllBrands.Delete(); Boolean Found = AllBrands.ThisBrand.Find(PK); Assert.IsFalse(Found); }
protected void btnYes_Click(object sender, EventArgs e) { clsBrandCollection BrandsList = new clsBrandCollection(); // find the brand BrandsList.ThisBrand.Find(BrandID); // delete record BrandsList.Delete(); // redirect back to main page Response.Redirect("BrandsList.aspx"); }