public void AddMethod() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //create the item of test data clsPlane TestItem = new clsPlane(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.PlaneID = 1; TestItem.LocationID = 2; TestItem.PlaneName = "Emirates"; TestItem.HoursFly = 12; //set thisplane to the test data AllPlane.ThisPlane = TestItem; //add the record PrimaryKey = AllPlane.Add(); //set the primary key of the test data TestItem.PlaneID = PrimaryKey; //find the record AllPlane.ThisPlane.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllPlane.ThisPlane, TestItem); }
public void UpdateMethod() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //create the item of test data clsPlane TestItem = new clsPlane(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.LocationID = 2; TestItem.PlaneName = "Emirates"; TestItem.HoursFly = 12; //set thisplane to the test data AllPlane.ThisPlane = TestItem; //add the record PrimaryKey = AllPlane.Add(); //set the primary key of the test data TestItem.PlaneID = PrimaryKey; //modify the test data TestItem.LocationID = 3; TestItem.PlaneName = "FlyDubai"; TestItem.HoursFly = 2; //set the record based on the new test data AllPlane.ThisPlane = TestItem; //update the record AllPlane.Update(); //find the record AllPlane.ThisPlane.Find(PrimaryKey); //test to see thisplane matches the test data Assert.AreEqual(AllPlane.ThisPlane, TestItem); }
public void ReportByBookingNameTestDataFound() { //create an instance of the class containing unfiltered results clsPlaneCollection FilteredPlane = new clsPlaneCollection(); //var to store outcome Boolean OK = true; //apply a plane name that does not exist FilteredPlane.ReportByPlaneName("FlyDubaii"); //check that the correct number of records are found if (FilteredPlane.Count == 2) { //Check that the first record is ID 11 if (FilteredPlane.PlaneList[0].PlaneID != 11) { OK = false; } //Check that the first record is ID 14 if (FilteredPlane.PlaneList[1].PlaneID != 14) { OK = false; } } else { OK = false; } //test to see that there are no record Assert.IsTrue(OK); }
Int32 DisplayPlane(string PlaneNameFilter) { //var to store the PlaneName string PlaneName; //create an instance of customer collection class clsPlaneCollection Plane = new clsPlaneCollection(); Plane.ReportByPlaneName(PlaneNameFilter); //var to store the count of records Int32 RecordCount; //var to store the index for the loop Int32 Index = 0; //get the count of records RecordCount = Plane.Count; //clear the list box lstPlane.Items.Clear(); //while there are records while (Index < RecordCount) { //get the username PlaneName = Plane.PlaneList[Index].PlaneName; //create a new entry for th list box ListItem NewEntry = new ListItem(PlaneName + " ".ToString()); //add the plane to the list lstPlane.Items.Add(NewEntry); //move the index to the next record Index++; } //return to the count of records found return(RecordCount); }
public void DeleteMethod() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //create the item of test data clsPlane TestItem = new clsPlane(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.PlaneID = 1; TestItem.LocationID = 2; TestItem.PlaneName = "Emirates"; TestItem.HoursFly = 12; //set thisplane to the test data AllPlane.ThisPlane = TestItem; //add the record PrimaryKey = AllPlane.Add(); //set the primary key of the test data TestItem.PlaneID = PrimaryKey; //find the record AllPlane.ThisPlane.Find(PrimaryKey); //delete the record AllPlane.Delete(); //now find the record Boolean Found = AllPlane.ThisPlane.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
//this function handles the load object for the page protected void Page_Load(object sender, EventArgs e) { //if this is the first time the page is displayed if (IsPostBack == false) { //update the list box DisplayPlane(); } void DisplayPlane() { //create an instance of the plane collection clsPlaneCollection Plane = new clsPlaneCollection(); //set the data source to the list of bookings in the collection lstPlane.DataSource = Plane.PlaneList; //set the name of the primary key lstPlane.DataValueField = "PlaneID"; //set the data field to display lstPlane.DataTextField = "PlaneName"; //bind the data source to the list lstPlane.DataBind(); } }
//function for updating new records void Update() { //create an instance of a class clsPlaneCollection PlaneBook = new clsPlaneCollection(); //validate the data on the web form string Error = PlaneBook.ThisPlane.Valid(txtPlaneName.Text, txtHoursFly.Text); //if the data is ok then add it to the object if (Error == "") { //find the record to update PlaneBook.ThisPlane.Find(PlaneID); //get the data entered by the user PlaneBook.ThisPlane.PlaneName = txtPlaneName.Text; PlaneBook.ThisPlane.HoursFly = Convert.ToInt32(txtHoursFly.Text); //Update the record PlaneBook.Update(); //all done so redirect back to the main page Response.Redirect("PlaneList.aspx"); } else { //report the error lblError.Text = "There were problems with the data entered " + Error; } }
public void InstanceOK() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //test to see that it exists Assert.IsNotNull(AllPlane); }
public void ReportByPlaneNameNoneFoundMethod() { //create an instance of the class containing unfiltered results clsPlaneCollection FilteredPlane = new clsPlaneCollection(); //apply a plane name that doesnt exist FilteredPlane.ReportByPlaneName("XXXX"); //test to see that there are no records Assert.AreEqual(0, FilteredPlane.Count); }
void DisplayPlane() { //create an instance of the plane book clsPlaneCollection PlaneBook = new clsPlaneCollection(); //find the record to update PlaneBook.ThisPlane.Find(PlaneID); //display the data for this record txtPlaneName.Text = PlaneBook.ThisPlane.PlaneName; txtHoursFly.Text = PlaneBook.ThisPlane.HoursFly.ToString(); }
public void ReportByPlaneNameMethod() { //create an instance of the class containing unfiltered results clsPlaneCollection AllPlane = new clsPlaneCollection(); //create an instance of the filtered data clsPlaneCollection FilteredPlane = new clsPlaneCollection(); //apply a blank string (should return all records) FilteredPlane.ReportByPlaneName(""); //test to see that the two values are the same Assert.AreEqual(AllPlane.Count, FilteredPlane.Count); }
void DeletePlane() { //function to delete the selected record //create a new instance of the Booking book clsPlaneCollection PlaneBook = new clsPlaneCollection(); //find the record to delete PlaneBook.ThisPlane.Find(PlaneID); //delete the record PlaneBook.Delete(); }
public void ThisPlaneProperty() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //create some test data to assign to the property clsPlane TestPlane = new clsPlane(); //set the properties of the test object TestPlane.PlaneID = 1; TestPlane.LocationID = 2; TestPlane.PlaneName = "Emirates"; TestPlane.HoursFly = 12; //assign the data to the property AllPlane.ThisPlane = TestPlane; //test to see that the two values are the same Assert.AreEqual(AllPlane.ThisPlane, TestPlane); }
public void ListAndCount() { //create an instance of a class clsPlaneCollection AllPlane = new clsPlaneCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsPlane> TestList = new List <clsPlane>(); //add an item to the list //create the item of test data clsPlane TestItem = new clsPlane(); //set its properties TestItem.PlaneID = 1; TestItem.LocationID = 2; TestItem.PlaneName = "Emirates"; TestItem.HoursFly = 12; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllPlane.PlaneList = TestList; //test to see that the two values are the same Assert.AreEqual(AllPlane.Count, TestList.Count); }