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 btnOK_Click(object sender, EventArgs e)
    {
        ClsCar ACar        = new ClsCar();
        String NumberPlate = txtNumberPlate.Text;
        String Make        = txtMake.Text;
        String Model       = txtModel.Text;
        String Colour      = txtColour.Text;
        String Description = txtDescription.Text;
        String Price       = txtPrice.Text;
        String OfficeCode  = txtOfficeCode.Text;

        String Error = "";

        Error = ACar.Valid(NumberPlate, Make, Model, Description, Colour, Price);
        if (Error == "")
        {
            ACar.NumberPlate = NumberPlate;
            ACar.Make        = Make;
            ACar.Model       = Model;
            ACar.Colour      = Colour;
            ACar.Description = Description;
            ACar.Price       = Convert.ToInt32(Price);
            ACar.OfficeCode  = Convert.ToInt32(OfficeCode);

            ClsCarCollection CarList = new ClsCarCollection();

            //if this is a new record i.e. NumberPlate != -1 then add the data
            if (CarID == -1)
            {
                //set the ThisCar Property
                CarList.ThisCar = ACar;
                //add the new record
                CarList.Add();
            }
            //otherwise it must be an update
            else
            {
                //find the record to update
                CarList.ThisCar.Find(CarID);
                //set the ThisCar property
                CarList.ThisCar = ACar;
                //update the record
                CarList.Update();
            }
            //redirect back to thte list page
            Response.Redirect("CarList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
        public void UpdateMethodOK()
        {
            //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;
            //modify the test data
            TestItem.NumberPlate = "4567 HGTY";
            TestItem.Make        = "BMW";
            TestItem.Model       = "A5";
            TestItem.Colour      = "Green";
            TestItem.Description = "2 wheeler";
            TestItem.Sold        = false;
            TestItem.Price       = 200.00;
            TestItem.OfficeCode  = 2;
            //set the record based on the new data
            AllCars.ThisCar = TestItem;
            //update the record
            AllCars.Update();
            //find the record
            AllCars.ThisCar.Find(PrimaryKey);
            //test to see ThisCar matches the test data
            Assert.AreEqual(AllCars.ThisCar, TestItem);
        }