Exemplo n.º 1
0
        public void CarDeleteMethodOK()
        {
            //create an instance of the class we want to create.
            clsCarsCollection AllCars = new clsCarsCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //variable to store the primary key.
            Int32 PrimaryKey = 0;

            //set it's properties.
            TestItem.CarID                = 4;
            TestItem.CarManufacturer      = "BMW";
            TestItem.CarModel             = "i8";
            TestItem.CarRegistrationPlate = "FE17 GTE";
            TestItem.CarColour            = "yellow";
            TestItem.CarNumberOfDoors     = 5;
            TestItem.CarNumberOfSeats     = 5;
            TestItem.CarNeedsRepair       = false;
            TestItem.CarSold              = true;
            //set thiscar to the test date
            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);
        }
Exemplo n.º 2
0
        public void UpdateMethodOK()
        {
            clsCarsCollection AllCars    = new clsCarsCollection();
            clsCars           TestCar    = new clsCars();
            Int32             PrimaryKey = 0;

            TestCar.CarMake        = "Mercedes";
            TestCar.CarModel       = "S Class";
            TestCar.CarModelNumber = "VRi122";
            TestCar.CarColour      = "Blue";
            TestCar.CarPrice       = 1;
            TestCar.CarTypeNumber  = 1;
            TestCar.CarReleaseDate = "11/10/2001";
            AllCars.ThisCar        = TestCar;
            PrimaryKey             = AllCars.Add();
            TestCar.CarNo          = PrimaryKey;
            TestCar.CarMake        = "Mer";
            TestCar.CarModel       = "SAClass";
            TestCar.CarModelNumber = "Vi122";
            TestCar.CarColour      = "Black";
            TestCar.CarPrice       = 2;
            TestCar.CarTypeNumber  = 3;
            TestCar.CarReleaseDate = "30/11/2015";
            AllCars.ThisCar        = TestCar;
            AllCars.Update();
            AllCars.ThisCar.Find(PrimaryKey);
            Assert.AreEqual(AllCars.ThisCar, TestCar);
        }
Exemplo n.º 3
0
        public void CarUpdateMethodOk()
        {
            //create an instance of the class we want to create.
            clsCarsCollection AllCars = new clsCarsCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //variable to store the primary key.
            Int32 PrimaryKey = 0;

            //set it's properties.
            TestItem.CarManufacturer      = "BMW";
            TestItem.CarModel             = "i8";
            TestItem.CarRegistrationPlate = "FE17 GTE";
            TestItem.CarColour            = "yellow";
            TestItem.CarNumberOfDoors     = 5;
            TestItem.CarNumberOfSeats     = 5;
            TestItem.CarNeedsRepair       = false;
            TestItem.CarSold = true;
            //set thiscar to the test date
            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.CarManufacturer      = "Audi";
            TestItem.CarModel             = "s5";
            TestItem.CarRegistrationPlate = "FE15 EDS";
            TestItem.CarColour            = "White";
            TestItem.CarNumberOfDoors     = 3;
            TestItem.CarNumberOfSeats     = 5;
            TestItem.CarNeedsRepair       = true;
            TestItem.CarSold = false;
            //set the record based on the new test 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);
        }
Exemplo n.º 4
0
    void Add()
    {
        //function to add a car.
        //create an instance
        clsCarsCollection Cars = new clsCarsCollection();
        //validate the data on the web form
        Boolean OK = Cars.ThisCar.Valid(txtReceptionistCarManufacturer.Text, txtReceptionistCarModel.Text, txtReceptionistCarRegistrationPlate.Text, txtReceptionistCarColour.Text, txtReceptionistCarNumberOfDoors.Text, txtReceptionistCarNumberOfSeats.Text, txtReceptionistSupplierID.Text);

        //if the data is OK then add it to the object.
        if (OK == true)
        {
            //get the data entered by the user.
            Cars.ThisCar.CarManufacturer      = txtReceptionistCarManufacturer.Text;
            Cars.ThisCar.CarModel             = txtReceptionistCarModel.Text;
            Cars.ThisCar.CarRegistrationPlate = txtReceptionistCarRegistrationPlate.Text;
            Cars.ThisCar.CarColour            = txtReceptionistCarColour.Text;
            Cars.ThisCar.CarNumberOfDoors     = Convert.ToInt32(txtReceptionistCarNumberOfDoors.Text);
            Cars.ThisCar.CarNumberOfSeats     = Convert.ToInt32(txtReceptionistCarNumberOfSeats.Text);
            Cars.ThisCar.CarNeedsRepair       = Convert.ToBoolean(ChkBoxReceptionistNeedsRepair.Checked);
            Cars.ThisCar.CarSold    = Convert.ToBoolean(ChkBoxReceptionistSold.Checked);
            Cars.ThisCar.SupplierID = Convert.ToInt32(txtReceptionistSupplierID.Text);
            //test to see if the registration exists.
            if (Convert.ToInt32(Cars.CarRegistrationExists()) == 0)
            {
                lblError.Text = "Car Reg already exists";
            }
            else
            {
                //add the record.
                Cars.Add();
                //set lbl to empty
                lblError.Text = "";
                //reload/refresh the page.
                Response.Redirect("ReceptionistHomepage.aspx");
            }
        }
        else
        {
            //report the error
            lblError.Text = "There were problems with the data entered";
        }
    }
Exemplo n.º 5
0
    void Add()
    {
        clsCarsCollection CarShop = new clsCarsCollection();
        String            Error   = CarShop.ThisCar.Valid(txtCarMake.Text, txtCarModel.Text, txtCarModelNumber.Text, txtCarColour.Text, txtCarRDate.Text, Convert.ToInt32(txtCarPrice.Text));

        if (Error == "")
        {
            CarShop.ThisCar.CarMake        = txtCarMake.Text;
            CarShop.ThisCar.CarModel       = txtCarModel.Text;
            CarShop.ThisCar.CarModelNumber = txtCarModelNumber.Text;
            CarShop.ThisCar.CarColour      = txtCarColour.Text;
            CarShop.ThisCar.CarReleaseDate = txtCarRDate.Text;
            CarShop.ThisCar.CarPrice       = Convert.ToInt32(txtCarPrice.Text);
            CarShop.ThisCar.CarTypeNumber  = Convert.ToInt32(drpCarType.SelectedValue);
            CarShop.Add();
        }
        else
        {
            lblError.Text = "There were problem with the data entered " + Error;
        }
    }
Exemplo n.º 6
0
        public void DeleteMethodOK()
        {
            clsCarsCollection AllCars    = new clsCarsCollection();
            clsCars           TestCar    = new clsCars();
            Int32             PrimaryKey = 0;

            TestCar.CarNo          = 1;
            TestCar.CarMake        = "Mercedes";
            TestCar.CarModel       = "S Class";
            TestCar.CarModelNumber = "VRi122";
            TestCar.CarColour      = "Blue";
            TestCar.CarPrice       = 1;
            TestCar.CarTypeNumber  = 1;
            TestCar.CarReleaseDate = "11/10/2001";
            AllCars.ThisCar        = TestCar;
            PrimaryKey             = AllCars.Add();
            TestCar.CarNo          = PrimaryKey;
            AllCars.ThisCar.Find(PrimaryKey);
            AllCars.Delete();
            Boolean Found = AllCars.ThisCar.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }