public void DeleteMethodOK() { //create an instance of the calss we want to create ClsCarCollection AllCars = new ClsCarCollection(); //create the item of test data ClsCar TestItem = new ClsCar(); int PrimaryKey = 0; //set its propertiers TestItem.NumberPlate = "1234 ABCD"; TestItem.Make = "Nissan"; TestItem.Model = "Micra"; TestItem.Colour = "Blue"; TestItem.Description = "4 wheeler"; TestItem.Sold = true; TestItem.Price = 100.00; TestItem.OfficeCode = 1; //set ThisAddress to the test data AllCars.ThisCar = TestItem; //add the record PrimaryKey = AllCars.Add(); //set the primary key of the test data TestItem.CarID = PrimaryKey; //find the record AllCars.ThisCar.Find(PrimaryKey); //delete the record AllCars.Delete(); //now find the record Boolean Found = AllCars.ThisCar.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
protected void BtnYes_Click(object sender, EventArgs e) { //create an instance of the car collection ClsCarCollection AllCars = new ClsCarCollection(); //find the record to delete AllCars.ThisCar.Find(CarID); //delete the record AllCars.Delete(); //redirect back to main page Response.Redirect("CarList.aspx"); }