public void AddMethodOK() { //create an instance of the class we want to create clsConsultantCollection AllConsultants = new clsConsultantCollection(); clsConsultant TestItem = new clsConsultant(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Status = true; TestItem.ConsultantNo = 120; TestItem.FirstName = "James"; TestItem.LastName = "Junior"; TestItem.DateOfBirth = DateTime.Now.Date.AddYears(-17); TestItem.Address = "Flat C, Colly road"; TestItem.Email = "*****@*****.**"; TestItem.TelephoneNo = "07437320192"; TestItem.EmergencyContact = "07528789924"; TestItem.EmploymentDate = DateTime.Now.Date; TestItem.HoursOfWork = 129; TestItem.EmploymentHistory = "None"; TestItem.DateAdded = DateTime.Now.Date; //set ThisConsultant to the test data AllConsultants.ThisConsultant = TestItem; //add the record PrimaryKey = AllConsultants.AddNew(); //set the primary key of the test data TestItem.ConsultantNo = PrimaryKey; //find the record AllConsultants.ThisConsultant.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllConsultants.ThisConsultant, TestItem); }
void Add() { //create an instance of TNovation clsConsultantCollection TNovation = new clsConsultantCollection(); //this line of code validates the data on the webform Boolean OK = TNovation.ThisConsultant.Valid(textBoxfirstName.Text, textBoxlastName.Text, textBoxAddress.Text, textBoxEmail.Text, textBoxEhist.Text, textBoxDOB.Text); //if the data is OK then add it to the object if (OK == true) { //get the data entered by the user TNovation.ThisConsultant.ConsultantNo = Convert.ToInt32(textBoxNo.Text); TNovation.ThisConsultant.FirstName = textBoxfirstName.Text; TNovation.ThisConsultant.LastName = textBoxlastName.Text; TNovation.ThisConsultant.DateOfBirth = Convert.ToDateTime(textBoxDOB.Text); TNovation.ThisConsultant.Address = textBoxAddress.Text; TNovation.ThisConsultant.Email = textBoxEmail.Text; TNovation.ThisConsultant.TelephoneNo = textBoxTelno.Text; TNovation.ThisConsultant.EmergencyContact = textBoxEmerg.Text; TNovation.ThisConsultant.EmploymentDate = Convert.ToDateTime(textBoxDate.Text); TNovation.ThisConsultant.HoursOfWork = Convert.ToInt32(textBoxHours.Text); TNovation.ThisConsultant.EmploymentHistory = textBoxEhist.Text; TNovation.ThisConsultant.DateAdded = Convert.ToDateTime(textBoxDateAdded.Text); //add the new entry TNovation.AddNew(); } }
public void DeleteMethodOK() { //create an instance of the class we want to create clsConsultantCollection AllConsultants = new clsConsultantCollection(); clsConsultant TestItem = new clsConsultant(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Status = true; TestItem.ConsultantNo = 119; TestItem.FirstName = "James"; TestItem.LastName = "Junior"; TestItem.DateOfBirth = DateTime.Now.Date.AddYears(-17); TestItem.Address = "Flat C, Basil road"; TestItem.Email = "*****@*****.**"; TestItem.TelephoneNo = "07528789965"; TestItem.EmergencyContact = "07528789965"; TestItem.EmploymentDate = DateTime.Now.Date; TestItem.HoursOfWork = 129; TestItem.EmploymentHistory = "None"; TestItem.DateAdded = DateTime.Now.Date; //set ThisConsultant to the test data AllConsultants.ThisConsultant = TestItem; //add the record PrimaryKey = AllConsultants.AddNew(); //set the primary key of the test data TestItem.ConsultantNo = PrimaryKey; //find the record AllConsultants.ThisConsultant.Find(PrimaryKey); //delete the record AllConsultants.Delete(); //now find the record Boolean Found = AllConsultants.ThisConsultant.Find(PrimaryKey); //test to see that the record wasn't found Assert.IsFalse(Found); }