void DeleteCars() { clsCarsCollection CarShop = new clsCarsCollection(); CarShop.ThisCar.Find(CarNo); CarShop.Delete(); }
public void FilterByCarManufacturerDataFound() { //create an instance of the filtered data. clsCarsCollection FilteredCars = new clsCarsCollection(); //Variable to store the result. Boolean Ok = true; //apply a car manufacturer that doesn't exist. FilteredCars.FilterByCarManufacturer("Doesntexist"); //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].CarID != 1) { Ok = false; } //check that the first record is ID 2 if (FilteredCars.CarList[1].CarID != 2) { Ok = false; } else { Ok = false; } //test to see that there are no records. Assert.IsTrue(Ok); } }
void Update() //function for updating records. { //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) { //find the record to update. Cars.ThisCar.Find(CarID); //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 = ChkBoxReceptionistNeedsRepair.Checked; Cars.ThisCar.CarSold = ChkBoxReceptionistSold.Checked; Cars.ThisCar.SupplierID = Convert.ToInt32(txtReceptionistSupplierID.Text); //update the record Cars.Update(); lblError.Text = ""; Response.Redirect("ReceptionistHomepage.aspx"); } else { //report an error lblError.Text = "There were problems with the data you have entered."; } }
public void CarsListAndCountOK() { //Create an instance of the class we want to create. clsCarsCollection AllCars = new clsCarsCollection(); //Create some test data to assign to the property. //In this case data needs to be a list of objects. List <clsCar> TestList = new List <clsCar>(); //Add item to the list //Create the item of test data clsCar TestItem = new clsCar(); //Set it's properties TestItem.CarManufacturer = "Volkswagon"; TestItem.CarModel = "Golf R"; TestItem.CarRegistrationPlate = "DE17 FGH"; TestItem.CarColour = "Yellow"; TestItem.CarNumberOfDoors = 5; TestItem.CarNumberOfSeats = 5; TestItem.CarNeedsRepair = true; TestItem.CarSold = false; //Add the items 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 CarAddMethodOK() { //Create an instance of the class we want to create clsCarsCollection AllCars = new clsCarsCollection(); //Create the item for test data. clsCar TestItem = new clsCar(); //Var to store the primary key Int32 PrimaryKey = 0; //set it's properties TestItem.CarID = 1; TestItem.CarManufacturer = "Mini"; TestItem.CarModel = "Paceman"; TestItem.CarRegistrationPlate = "FE64 JUI"; TestItem.CarColour = "White"; TestItem.CarNumberOfDoors = 5; TestItem.CarNumberOfSeats = 4; TestItem.SupplierID = 4; TestItem.CarNeedsRepair = false; TestItem.CarSold = false; //Set thiscar to the test data. AllCars.ThisCar = TestItem; //Find the record AllCars.ThisCar.Find(PrimaryKey); //Test to see if the two values are the same. Assert.AreEqual(AllCars.ThisCar, TestItem); }
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); }
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); }
public void ReportByCarModel() { clsCarsCollection AllCars = new clsCarsCollection(); clsCarsCollection FilteredCarModel = new clsCarsCollection(); FilteredCarModel.ReportByCarModel(""); Assert.AreEqual(AllCars.Count, FilteredCarModel.Count); }
public void CarsInstanceOK() { //Create an instance of the class we want to create. clsCarsCollection AllCars = new clsCarsCollection(); //Tests to see that it exists Assert.IsNotNull(AllCars); }
public void ReportByCarColour() { clsCarsCollection AllCars = new clsCarsCollection(); clsCarsCollection FilteredCarColour = new clsCarsCollection(); FilteredCarColour.ReportByCarColour(""); Assert.AreEqual(AllCars.Count, FilteredCarColour.Count); }
public void FilterByCarManufacturerNoneFound() { //create an instance of the filtered data. clsCarsCollection FilteredCars = new clsCarsCollection(); //Apply a blank string (Should return all records) FilteredCars.FilterByCarManufacturer("TestManufacturer"); //Test to see that there are no records. Assert.AreEqual(0, FilteredCars.Count); }
void CarRegExists() //funtion to test if the car registration exists. { //create instance of class. clsCarsCollection Cars = new clsCarsCollection(); //get the car registration plate entered by the user. Cars.ThisCar.CarRegistrationPlate = txtReceptionistCarRegistrationPlate.Text; //check the registration. Cars.CarRegistrationExists(); }
void FetchCarID() { //set variable equal to the session number CarID = Convert.ToInt32(Session["CarID"]); //Create instance in car class clsCarsCollection Car = new clsCarsCollection(); //run carId through the find function Car.ThisCar.Find(CarID); //assign the data from record in the database to the text box txtMechanicCarID.Text = Car.ThisCar.CarID.ToString(); }
protected void btnApplyCarMake_Click(object sender, EventArgs e) { string Filter = txtFilterCarMake.Text; clsCarsCollection Cars = new clsCarsCollection(); Cars.ReportByCarMake(Filter); lstCarList.Items.Clear(); lstCarList.DataSource = Cars.CarList; lstCarList.DataValueField = "CarNo"; lstCarList.DataTextField = "CarMake"; lstCarList.DataBind(); }
public void FilterByCarManufacturerMethodOk() { //Create an instance of the class containing unfiltered results. clsCarsCollection AllCars = new clsCarsCollection(); //create an instance of the filtered data. clsCarsCollection FilteredCars = new clsCarsCollection(); //Apply a blank string (Should return all records) FilteredCars.FilterByCarManufacturer(""); //Test to see that the two values are the same. Assert.AreEqual(AllCars.Count, FilteredCars.Count); }
void ArchiveAndDeleteCar() { //function to Archive and delete the selected record. //create a new instance clsCarsCollection Cars = new clsCarsCollection(); //find the record to delete Cars.ThisCar.Find(CarID); //Delete the record Cars.ArchiveAndDelete(); }
void DisplayCars() { clsCarsCollection CarShop = new clsCarsCollection(); CarShop.ThisCar.Find(CarNo); txtCarMake.Text = CarShop.ThisCar.CarMake; txtCarModel.Text = CarShop.ThisCar.CarModel; txtCarModelNumber.Text = CarShop.ThisCar.CarModelNumber; txtCarPrice.Text = CarShop.ThisCar.CarPrice.ToString(); txtCarColour.Text = CarShop.ThisCar.CarColour; txtCarRDate.Text = CarShop.ThisCar.CarReleaseDate; drpCarType.SelectedValue = CarShop.ThisCar.CarTypeNumber.ToString(); }
void DisplayAllCars() { //create an instance of the Cars collection. clsCarsCollection Cars = new clsCarsCollection(); //Set the data source to the list of cars in the collection. lstBoxReceptionistListCars.DataSource = Cars.CarList; //Set the name of the primary lstBoxReceptionistListCars.DataValueField = "CarID"; //set the data field to display. lstBoxReceptionistListCars.DataTextField = "CarRegistrationPlate"; //Bind the data to the list. lstBoxReceptionistListCars.DataBind(); }
public void ThisCarPropertyOK() { clsCarsCollection AllCars = new clsCarsCollection(); clsCars TestCar = new clsCars(); TestCar.CarNo = 1; TestCar.CarMake = "Nissan"; TestCar.CarModel = "Aki"; TestCar.CarModelNumber = "VRi122"; TestCar.CarPrice = 1; TestCar.CarColour = "Blue"; TestCar.CarTypeNumber = 1; TestCar.CarReleaseDate = "11/10/2001"; AllCars.ThisCar = TestCar; Assert.AreEqual(AllCars.ThisCar, TestCar); }
void FilterByCarManufacturer() { //create an instance of the class. clsCarsCollection Cars = new clsCarsCollection(); //get the manufacturer the user wants to filter by. Cars.FilterByCarManufacturer(txtReceptionistFilterByCarManufacturer.Text); //Set the data source to the list of cars in the collection. lstBoxReceptionistListCars.DataSource = Cars.CarList; //Set the name of the primary lstBoxReceptionistListCars.DataValueField = "CarID"; //set the data field to display. lstBoxReceptionistListCars.DataTextField = "CarRegistrationPlate"; //Bind the data to the list. lstBoxReceptionistListCars.DataBind(); }
void FilterByRegPlate() { //create an instance clsCarsCollection Cars = new clsCarsCollection(); //Pass the text box value through the filter method Cars.ThisCar.CarRegistrationPlate = txtMechanicRegPlateFilter.Text; Cars.FilterByRegPlate(Cars.ThisCar.CarRegistrationPlate); //set the datasource for the list boc to the car repair list lstMechanicRepairs.DataSource = Cars.CarList; //Show the part required field in the list lstMechanicRepairs.DataValueField = "CarID"; //Show the part required field in the list lstMechanicRepairs.DataTextField = "CarRegistrationPlate"; //Bind the data to the list lstMechanicRepairs.DataBind(); }
public void ListAndCountOK() { clsCarsCollection AllCars = new clsCarsCollection(); List <clsCars> TestList = new List <clsCars>(); clsCars TestCar = new clsCars(); TestCar.CarNo = 1; TestCar.CarMake = "Nissan"; TestCar.CarModel = "Aki"; TestCar.CarModelNumber = "VRi122"; TestCar.CarColour = "Blue"; TestCar.CarPrice = 1; TestCar.CarTypeNumber = 1; TestCar.CarReleaseDate = "11/10/2001"; TestList.Add(TestCar); AllCars.CarList = TestList; Assert.AreEqual(AllCars.Count, TestList.Count); }
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); }
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"; } }
public void CarsThisCarPropertyOk() { //Create an instance of the class we want to create. clsCarsCollection AllCars = new clsCarsCollection(); //Create some test data to assign to the property. clsCar TestCar = new clsCar(); //Set the properties of the test object. TestCar.CarManufacturer = "Volkswagon"; TestCar.CarModel = "Golf R"; TestCar.CarRegistrationPlate = "DE17 FGH"; TestCar.CarColour = "Yellow"; TestCar.CarNumberOfDoors = 5; TestCar.CarNumberOfSeats = 5; TestCar.CarNeedsRepair = true; TestCar.CarSold = false; //Assign the data to the property. AllCars.ThisCar = TestCar; //Test to see that the two values are the same. Assert.AreEqual(AllCars.ThisCar, TestCar); }
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; } }
void DisplayCar() { //get the number of the Car to be processed. CarID = Convert.ToInt32(Session["CarID"]); //create an instance. clsCarsCollection Cars = new clsCarsCollection(); //find the record to be displayed. Cars.ThisCar.Find(CarID); //copy properties into textboxes on web form. txtReceptionistCarID.Text = Convert.ToString(Cars.ThisCar.CarID); txtReceptionistCarManufacturer.Text = Cars.ThisCar.CarManufacturer; txtReceptionistCarModel.Text = Cars.ThisCar.CarModel; txtReceptionistCarRegistrationPlate.Text = Cars.ThisCar.CarRegistrationPlate; txtReceptionistCarColour.Text = Cars.ThisCar.CarColour; txtReceptionistCarNumberOfDoors.Text = Convert.ToString(Cars.ThisCar.CarNumberOfDoors); txtReceptionistCarNumberOfSeats.Text = Convert.ToString(Cars.ThisCar.CarNumberOfSeats); ChkBoxReceptionistNeedsRepair.Checked = Cars.ThisCar.CarNeedsRepair; ChkBoxReceptionistSold.Checked = Cars.ThisCar.CarSold; txtReceptionistSupplierID.Text = Convert.ToString(Cars.ThisCar.SupplierID); }
void Update() { 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.Find(CarNo); 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.Update(); Response.Redirect("Default.aspx"); } else { lblError.Text = "There was a problem with he data entered" + Error; } }
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); }
public void InstanceOK() { clsCarsCollection AllCars = new clsCarsCollection(); Assert.IsNotNull(AllCars); }