public void CarParkReservationOk() { //create an instance of the class we want to create clscarparkCollection AllCarPark = new clscarparkCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsCarPark> TestList = new List <clsCarPark>(); //add an item to the list //create the item of test data clsCarPark TestItem = new clsCarPark(); //set its properties TestItem.carparkid = 1; TestItem.CarReg = "DEO3 CHO"; TestItem.BookingDate = DateTime.Now.Date; TestItem.EndDate = DateTime.Now.Date; TestItem.StartDate = DateTime.Now.Date; TestItem.Location = "B2"; //add the item to the list TestList.Add(TestItem); //assign the data To property AllCarPark.CarParkList = TestList; //test to see that the two values are the same Assert.AreEqual(AllCarPark.CarParkList, TestList); }
public void CarParkDeleteMethodOk() { //create an instance of the class we want to create clscarparkCollection AllCarPark = new clscarparkCollection(); //create the item of test data clsCarPark TestItem = new clsCarPark(); // car to store the rpimary key Int32 PrimaryKey = 0; //set its properties TestItem.carparkid = 3; TestItem.CarReg = "hiup b4u"; TestItem.BookingDate = DateTime.Now.Date; TestItem.EndDate = DateTime.Now.Date; TestItem.StartDate = DateTime.Now.Date; TestItem.Location = "B3"; //set thiscar park to the test data AllCarPark.ThisCarPark = TestItem; //add the record PrimaryKey = AllCarPark.Add(); // set the primary key of the data TestItem.carparkid = PrimaryKey; //find the record AllCarPark.ThisCarPark.Find(PrimaryKey); //delete the record AllCarPark.Delete(); //now find the record Boolean Found = AllCarPark.ThisCarPark.Find(PrimaryKey); //test to see that the two values are the same Assert.IsFalse(Found); }
void PopulateArray(clsDataConnection DB) { //populate the array list based on the data table on the parameter DB //var for the index Int32 Index = 0; //Var to store the record count Int32 RecordCount; //get the count of the record RecordCount = DB.Count; //clear the private array list mCarParkList = new List <clsCarPark>(); //while there are records to process while (Index < RecordCount) { //create a blank record clsCarPark acarpark = new clsCarPark(); // read in the fields from the current record acarpark.carparkid = Convert.ToInt32(DB.DataTable.Rows[Index]["CarParkId"]); acarpark.BookingDate = Convert.ToDateTime(DB.DataTable.Rows[Index]["BookingDate"]); acarpark.CarReg = Convert.ToString(DB.DataTable.Rows[Index]["CarReg"]); acarpark.StartDate = Convert.ToDateTime(DB.DataTable.Rows[Index]["StartDate"]); acarpark.EndDate = Convert.ToDateTime(DB.DataTable.Rows[Index]["EndDate"]); acarpark.Location = Convert.ToString(DB.DataTable.Rows[Index]["Location"]); acarpark.Price = Convert.ToDecimal(DB.DataTable.Rows[Index]["Price"]); //add the record to the private data member mCarParkList.Add(acarpark); //point at the next record Index++; } }
public void FindmethodOk() { // create an instance of a class we want to create clsCarPark Astaff = new clsCarPark(); // boolean variable Boolean Found = false; // test data to use with the method Int32 staffNo = 1; // execute the method Found = Astaff.Find(staffNo); // test to see that the result is correct Assert.IsTrue(Found); }