public void DeleteMethodOK() { //Create an instance of the class we want to create clsCourseCollection AllCourses = new clsCourseCollection(); //create the item of test data clsCourses TestItem = new clsCourses(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Available = true; TestItem.IDno = 1; TestItem.Title = "Web Development"; TestItem.Category = "Technology"; TestItem.Tutor = "R Sunderland"; TestItem.LiveDate = DateTime.Now.Date; TestItem.Price = 180; //set ThisCourse to the test data AllCourses.ThisCourse = TestItem; //add the record PrimaryKey = AllCourses.Add(); //set the primary key of the test data TestItem.IDno = PrimaryKey; //find the record AllCourses.ThisCourse.Find(PrimaryKey); //delete the record AllCourses.Delete(); //now find the record Boolean Found = AllCourses.ThisCourse.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
protected void btnYes_Click(object sender, EventArgs e) { //create a new instance of the courses clsCourseCollection CourseBook = new clsCourseCollection(); //find the record to delete CourseBook.ThisCourse.Find(IDno); //delete the record CourseBook.Delete(); //redirect back to the main page Response.Redirect("CourseList.aspx"); }