Esempio n. 1
0
        public void DeleteMethodOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //var to store the prim key
            Int32 PrimaryKey = 0;

            //set its proprties
            TestItem.RegPlate   = "dy20abc";
            TestItem.CarName    = "Audi";
            TestItem.CarModel   = "S5";
            TestItem.CarColour  = "Blue";
            TestItem.EngineSize = "2949cc";
            TestItem.Price      = 150;
            //set this cars to the test data
            AllCars.ThisCar = TestItem;
            //add record
            PrimaryKey = AllCars.Add();
            //set the prim key of the test data
            TestItem.CarID = PrimaryKey;
            //find the record
            AllCars.ThisCar.Find(PrimaryKey);
            //delte record
            AllCars.Delete();
            //find record
            Boolean Found = AllCars.ThisCar.Find(PrimaryKey);

            //test to see recrod not found
            Assert.IsFalse(Found);
        }
        public void AddMethodOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //var to store the primary key
            int PrimaryKey = 0;

            //set its properties
            TestItem.CarNo    = 1;
            TestItem.CarMake  = "Honda";
            TestItem.CarModel = "Civic";
            TestItem.Colour   = "red";
            TestItem.BodyType = "Sedan";
            TestItem.Age      = 5;
            TestItem.Active   = true;
            TestItem.Mileage  = 100000;
            //set ThisCar to the test data
            AllCars.ThisCar = TestItem;
            //add the record
            PrimaryKey = AllCars.Add();
            //set the primary key of the test data
            TestItem.CarNo = PrimaryKey;
            //find the record
            AllCars.ThisCar.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.ThisCar, TestItem);
        }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Fuel     = true;
            TestItem.CarID    = 3;
            TestItem.ColourNo = 4;
            TestItem.CarName  = "Audi";
            TestItem.Model    = "A6 Sedan C8";
            TestItem.BodyType = "SUV";
            TestItem.Price    = 47739.99m;
            TestItem.Stock    = 3;
            TestItem.YearMade = DateTime.Now.Date;
            //set ThisCar 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);
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.ThisCar, TestItem);
        }
Esempio n. 4
0
    void Update()
    {
        //create an instance of the cars
        clsCarCollection CarBook = new clsCarCollection();
        //validate the data on the web form
        String Error = CarBook.ThisCar.Valid(txtCarName.Text, txtCarModel.Text, txtCarReg.Text, txtColour.Text, txtEngineSize.Text, txtPrice.Text);

        //if data is ok add to object
        if (Error == "")
        {
            CarBook.ThisCar.Find(CarID);
            //get the data entrted by user
            CarBook.ThisCar.RegPlate   = txtCarReg.Text;
            CarBook.ThisCar.CarName    = txtCarName.Text;
            CarBook.ThisCar.CarModel   = txtCarModel.Text;
            CarBook.ThisCar.CarColour  = txtColour.Text;
            CarBook.ThisCar.EngineSize = txtEngineSize.Text;
            CarBook.ThisCar.Price      = Convert.ToInt32(txtPrice.Text);
            //add the records
            CarBook.Update();
            //all done so redirect back to the main page
            Response.Redirect("CarList.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the enterd data" + Error;
        }
    }
Esempio n. 5
0
        public void CarListAndCountOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsCar> Testlist = new List <clsCar>();
            //add an item to the list
            //create the item of test data
            clsCar TestItem = new clsCar();

            //set its proprties
            TestItem.CarID      = 1;
            TestItem.RegPlate   = "dy20abc";
            TestItem.CarName    = "Audi";
            TestItem.CarModel   = "S5";
            TestItem.CarColour  = "Blue";
            TestItem.EngineSize = "2949cc";
            TestItem.Price      = 150;
            //add the item to the test list
            Testlist.Add(TestItem);
            //assign the data to the property
            AllCars.CarList = Testlist;
            //test to see that the two values are the samw
            Assert.AreEqual(AllCars.CarList, Testlist);
        }
Esempio n. 6
0
        public void AddMethodOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create the item of test data
            clsCar TestItem = new clsCar();
            //var to store the prim key
            Int32 PrimaryKey = 0;

            //set its proprties
            TestItem.RegPlate   = "dy20abc";
            TestItem.CarName    = "Audi";
            TestItem.CarModel   = "S5";
            TestItem.CarColour  = "Blue";
            TestItem.EngineSize = "2949";
            TestItem.Price      = 150;
            //set this cars to the test data
            AllCars.ThisCar = TestItem;
            //add record
            PrimaryKey = AllCars.Add();
            //set the prim key of the test data
            TestItem.CarID = PrimaryKey;
            //find the record
            AllCars.ThisCar.Find(PrimaryKey);
            //test to see that the 2 values are the same
            Assert.AreEqual(AllCars.ThisCar, TestItem);
        }
Esempio n. 7
0
        public void ReportByRegPlateTestDataFound()
        {
            //create an instance of the filtered data
            clsCarCollection FilteredCars = new clsCarCollection();
            //var to sore outcome
            Boolean Ok = true;

            //apply a reg plate that doesnt exist
            FilteredCars.ReportByRegPlate("cd18hju");
            //check that the correct no of records are found
            if (FilteredCars.Count == 2)
            {
                //check that the first record is ID 4
                if (FilteredCars.CarList[0].CarID != 3)
                {
                    Ok = false;
                }
                //check that the first reocrd is ID 5
                if (FilteredCars.CarList[1].CarID != 193)
                {
                    Ok = false;
                }
            }
            else
            {
                Ok = false;
            }
            //test to see that there are no records
            Assert.IsTrue(Ok);
        }
        public void FilterByCarMakeTestDataFound()
        {
            //create an instance of the filtered data
            clsCarCollection FilteredCars = new clsCarCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a post code that doesn't exist
            FilteredCars.FilterByCarMake2("yyy yyy");
            //check that the correct number of records are found
            if (FilteredCars.Count == 2)
            {
                //check that the first record is ID 1
                if (FilteredCars.CarList[0].CarNo != 1)
                {
                    OK = false;
                }
                //check that the second record is ID 2
                if (FilteredCars.CarList[1].CarNo != 2)
                {
                    OK = false;
                }
            }
            else
            {
                OK = true;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
Esempio n. 9
0
    void DisplayCar(Int32 CarID)
    {
        //create an instance of the car log
        clsCarCollection CarLog = new clsCarCollection();

        //find the record to update
        CarLog.ThisCar.Find(CarID);
        //display the car name
        txtCarName.Text = CarLog.ThisCar.CarName;
        //display the model
        txtModel.Text = CarLog.ThisCar.Model;
        //display the body type
        txtBodyType.Text = CarLog.ThisCar.BodyType;
        //display the price
        txtPrice.Text = Convert.ToString(CarLog.ThisCar.Price);
        //display the stock
        txtStock.Text = Convert.ToString(CarLog.ThisCar.Stock);
        //display the year made
        txtYearMade.Text = CarLog.ThisCar.YearMade.ToString("dd/MM/yyyy");
        //display the check boxes
        chkDiesel.Checked = CarLog.ThisCar.Fuel = true;
        chkPetrol.Checked = CarLog.ThisCar.Fuel = false;
        //display the drop down list
        ddlColourNo.SelectedValue = Convert.ToString(CarLog.ThisCar.ColourNo);
    }
Esempio n. 10
0
    void Add()
    {
        //create an instance of the address book
        clsCarCollection CarBook = new clsCarCollection();
        //validate the data on the web form
        String Error = CarBook.ThisCar.Valid(ddlCarNo.Text, txtCarMake.Text, txtCarModel.Text, txtAge.Text, txtMileage.Text, txtBodyType.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //get the data entered by the user
            CarBook.ThisCar.CarNo    = Convert.ToInt32(ddlCarNo.Text);
            CarBook.ThisCar.CarMake  = txtCarMake.Text;
            CarBook.ThisCar.CarModel = txtCarModel.Text;
            CarBook.ThisCar.Age      = Convert.ToInt32(txtAge.Text);
            CarBook.ThisCar.Mileage  = Convert.ToInt32(txtMileage.Text);
            CarBook.ThisCar.Active   = chkActive.Checked;
            //add the record
            CarBook.Add();
            //all done so redirect back to the main page
            Response.Redirect("Default.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsCar> TestList = new List <clsCar>();
            //add an item to the list
            //create the item of test data
            clsCar TestItem = new clsCar();

            //set its properties
            TestItem.CarNo    = 1;
            TestItem.CarMake  = "Honda";
            TestItem.CarModel = "Civic";
            TestItem.Colour   = "red";
            TestItem.BodyType = "Sedan";
            TestItem.Age      = 5;
            TestItem.Active   = true;
            TestItem.Mileage  = 100000;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllCars.CarList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.Count, TestList.Count);
        }
        public void DeleteMethodOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllMainteance = new clsCarCollection();
            //create the item of test data
            clsMaintenance TestItem = new clsMaintenance();
            //var to store the primary key
            int PrimaryKey = 0;

            //set its properties
            TestItem.Active        = true;
            TestItem.MaintenanceID = 1;
            TestItem.Cost          = 1;
            TestItem.Date          = DateTime.Now.Date;
            TestItem.Description   = "something";
            TestItem.Repair        = true;
            //add the item
            //set ThisCar to the test data
            AllMainteance.ThisMaitenance = TestItem;
            //add the record
            PrimaryKey = AllMainteance.Add();
            //set the primary key of the test data
            AllMainteance.ThisCar.Find(PrimaryKey);
            //Delete
            AllMainteance.Delete();
            //now find the record
            Boolean Found = AllMainteance.ThisMaitenance.Find(PrimaryKey);

            //test to see that the two values are the same
            Assert.IsFalse(Found);
        }
Esempio n. 13
0
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsCar> TestList = new List <clsCar>();
            //add an item to the list
            //create the time of test data
            clsCar TestItem = new clsCar();

            //set its properties
            TestItem.Fuel     = true;
            TestItem.CarID    = 3;
            TestItem.ColourNo = 4;
            TestItem.CarName  = "Audi";
            TestItem.Model    = "A6 Sedan C8";
            TestItem.BodyType = "SUV";
            TestItem.Price    = 44737.99m;
            TestItem.Stock    = 3;
            TestItem.YearMade = DateTime.Now.Date;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllCars.CarList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.Count, TestList.Count);
        }
Esempio n. 14
0
    //function for adding new records
    void Add()
    {
        //create an instance of the cars
        clsCarCollection CarBook = new clsCarCollection();
        //validate the data on the web form
        String Error = CarBook.ThisCar.Valid(txtCarName.Text, txtCarModel.Text, txtCarReg.Text, txtColour.Text, txtEngineSize.Text, txtPrice.Text);

        //if data is ok add to object
        if (Error == "")
        {
            //get the data entrted by user
            CarBook.ThisCar.RegPlate   = txtCarReg.Text;
            CarBook.ThisCar.CarName    = txtCarName.Text;
            CarBook.ThisCar.CarModel   = txtCarModel.Text;
            CarBook.ThisCar.CarColour  = txtColour.Text;
            CarBook.ThisCar.EngineSize = txtEngineSize.Text;
            CarBook.ThisCar.Price      = Convert.ToInt32(txtPrice.Text);
            //add the records
            CarBook.Add();
            lblError.Text = "Success";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the enterd data" + Error;
        }
    }
Esempio n. 15
0
        public void TwoCarsPresent()
        {
            //create an instance of the class we want to create
            clsCarCollection Cars = new clsCarCollection();

            //test to see that the two values are the same
            Assert.AreEqual(Cars.Count, 2);
        }
Esempio n. 16
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();

            //test to see that it exists
            Assert.IsNotNull(AllCars);
        }
Esempio n. 17
0
        public void ReportByRegPlateNoneFound()
        {
            //create an instance of the filtered data
            clsCarCollection FilteredCars = new clsCarCollection();

            //apply a post code that doesnt exist
            FilteredCars.ReportByRegPlate("xxxx xxx");
            Assert.AreEqual(0, FilteredCars.Count);
        }
        public void FilterByCarMakeNoneFound()
        {
            //create an instance of the filtered data
            clsCarCollection FilteredCars = new clsCarCollection();

            //apply a Car Make that doesn't exist
            FilteredCars.FilterByCarMake2("jkjkjk");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredCars.Count);
        }
Esempio n. 19
0
        public void CountPropertyOK()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create some test data to assign to the property
            Int32 SomeCount = 2;

            //assign the data to the property
            AllCars.Count = SomeCount;
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.Count, SomeCount);
        }
Esempio n. 20
0
    void DeleteCar()
    {
        //function to delete the selected record

        //create a new instance of the car
        clsCarCollection CarLog = new clsCarCollection();

        //find the record to delete
        CarLog.ThisCar.Find(CarID);
        //delete the record
        CarLog.DeleteCar();
    }
        public void FilterByPostCodeMethodOK()
        {
            //create an instance of the class containing unfiltered results
            clsCarCollection AllCars = new clsCarCollection();
            //create an instance of the filtered data
            clsCarCollection FilteredCars = new clsCarCollection();

            //apply a blank string (should return all records);
            FilteredCars.FilterByCarMake2("");
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.Count, FilteredCars.Count);
        }
Esempio n. 22
0
    void DeleteCars()
    {
        //function to delete the selected record

        //create a new instance of the car book
        clsCarCollection CarBook = new clsCarCollection();

        //find the record to delete
        CarBook.ThisCar.Find(CarID);
        //delete record
        CarBook.Delete();
    }
Esempio n. 23
0
        public void ReportByRegPlateMethodOk()
        {
            //create an instance of the class containg unfiltered results
            clsCarCollection AllCars = new clsCarCollection();
            //create an instance of the filtere data
            clsCarCollection FilteredCars = new clsCarCollection();

            //apply a blank string (should return all records)
            FilteredCars.ReportByRegPlate("");
            //test to see that the 2 values are the same
            Assert.AreEqual(AllCars.Count, FilteredCars.Count);
        }
Esempio n. 24
0
    void DisplayCars()
    {
        //create an instance of the county collection
        clsCarCollection Cars = new clsCarCollection();

        //set the data source to the list of counties in the collection
        lstCars.DataSource = Cars.CarList;
        //set the name of the primariy key
        lstCars.DataValueField = "CarID";
        //set the data field to display
        lstCars.DataValueField = "RegPlate";
        //bind the data to the list
        lstCars.DataBind();
    }
Esempio n. 25
0
    void DisplayCars()
    {
        //CECK IF IN THE CORECT SPOT
        //create an instance of the car book
        clsCarCollection Carbook = new clsCarCollection();

        //find the record to update
        Carbook.ThisCar.Find(CarID);
        //display the data for this record
        txtCarReg.Text     = Carbook.ThisCar.RegPlate;
        txtCarName.Text    = Carbook.ThisCar.CarName;
        txtCarModel.Text   = Carbook.ThisCar.CarModel;
        txtColour.Text     = Carbook.ThisCar.CarColour;
        txtEngineSize.Text = Carbook.ThisCar.EngineSize;
        txtPrice.Text      = Carbook.ThisCar.Price.ToString();
    }
Esempio n. 26
0
    void DisplayCar()
    {
        //create an instance of the address book
        clsCarCollection CarBook = new clsCarCollection();

        //find the record to update
        CarBook.ThisCar.Find(CarNo);
        //display the data for this record
        ddlCarNo.SelectedValue = CarBook.ThisCar.CarNo.ToString();
        txtCarModel.Text       = CarBook.ThisCar.CarModel;
        txtCarMake.Text        = CarBook.ThisCar.CarMake;
        txtAge.Text            = CarBook.ThisCar.Age.ToString();
        txtBodyType.Text       = CarBook.ThisCar.BodyType;
        chkActive.Checked      = CarBook.ThisCar.Active;
        txtMileage.Text        = CarBook.ThisCar.Mileage.ToString();
    }
        public void ThisMaintenancePropertyOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllMaintenace = new clsCarCollection();
            //create some test data to assign to the property
            clsMaintenance TestMaitenance = new clsMaintenance();

            //set the properties of the test object
            TestMaitenance.Active        = true;
            TestMaitenance.MaintenanceID = 1;
            TestMaitenance.Cost          = 1;
            TestMaitenance.Date          = DateTime.Now.Date;
            TestMaitenance.Description   = "something";
            TestMaitenance.Repair        = true;
            //assign the data to the property
            AllMaintenace.ThisMaitenance = TestMaitenance;
            //test to see that the two values are the same
            Assert.AreEqual(AllMaintenace.ThisMaitenance, TestMaitenance);
        }
Esempio n. 28
0
        public void ThisCarPropertyOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllCars = new clsCarCollection();
            //create some test data to assign to the property
            clsCar TestCar = new clsCar();

            //set its proprties
            TestCar.CarID      = 1;
            TestCar.RegPlate   = "dy20abc";
            TestCar.CarName    = "Audi";
            TestCar.CarModel   = "S5";
            TestCar.CarColour  = "Blue";
            TestCar.EngineSize = "2949cc";
            TestCar.Price      = 150;
            //assign the data to the property
            AllCars.ThisCar = TestCar;
            //test to see that the two values are the same
            Assert.AreEqual(AllCars.ThisCar, TestCar);
        }
        public void ThisCarPropertyOk()
        {
            //create an instance of the class we want to create
            clsCarCollection AllAddresses = new clsCarCollection();
            //create some test data to assign to the property
            clsCar TestCar = new clsCar();

            //set the properties of the test object
            TestCar.CarNo    = 1;
            TestCar.CarMake  = "Honda";
            TestCar.CarModel = "Civic";
            TestCar.Colour   = "red";
            TestCar.BodyType = "Sedan";
            TestCar.Age      = 5;
            TestCar.Active   = true;
            TestCar.Mileage  = 100000;
            //assign the data to the property
            AllAddresses.ThisCar = TestCar;
            //test to see that the two values are the same
            Assert.AreEqual(AllAddresses.ThisCar, TestCar);
        }
Esempio n. 30
0
        public void CountMatchesList()
        {
            //create an instance of the class we want to create
            clsCarCollection Cars = new clsCarCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of objects
            List <clsCar> TestList = new List <clsCar>();
            //add an item to the list
            //create the item of test data
            clsCar TestItem = new clsCar();

            //set its properties
            TestItem.CarNo = 1;
            TestItem.Car   = "Ford";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            Cars.AllCars = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(Cars.Count, TestList.Count);
        }