public void ListAndCountOK() { //create an instance of the class we want to create clsTrainerCollection AllTrainers = new clsTrainerCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsTrainer> TestList = new List <clsTrainer>(); //add an item to the list //create the item of test data clsTrainer TestItem = new clsTrainer(); //set its properites TestItem.FullName = "Ross O'Donegan"; TestItem.Gender = "Male"; TestItem.EmailAddress = "*****@*****.**"; TestItem.DateOfBirth = DateTime.Parse("20/05/1999"); TestItem.TrainerID = 20; TestItem.Retrained = false; //add the item to the test list TestList.Add(TestItem); //asign the data to the property AllTrainers.TrainerList = TestList; //test to see that the wo values are the same Assert.AreEqual(AllTrainers.Count, TestList.Count); }
public void AddMethodOK() { //create an instance of the class we want to create clsTrainerCollection AllTrainers = new clsTrainerCollection(); //create the item of test data clsTrainer TestItem = new clsTrainer(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.TrainerID = 44; TestItem.FullName = "Ross O'Donegan"; TestItem.EmailAddress = "*****@*****.**"; TestItem.Gender = "Male"; TestItem.Retrained = true; TestItem.DateOfBirth = DateTime.Parse("17/05/2000"); //set ThisAddress to the test data AllTrainers.ThisTrainer = TestItem; //add the record PrimaryKey = AllTrainers.Add(); //set the primary key to the test data TestItem.TrainerID = PrimaryKey; //find the record AllTrainers.ThisTrainer.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllTrainers.ThisTrainer, TestItem); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsTrainerCollection AllTrainers = new clsTrainerCollection(); //create an item of test data clsTrainer TestItem = new clsTrainer(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.TrainerID = 44; TestItem.FullName = "Ross O'Donegan"; TestItem.EmailAddress = "*****@*****.**"; TestItem.Gender = "Male"; TestItem.Retrained = true; TestItem.DateOfBirth = DateTime.Parse("17/05/2000"); //set ThisTrainer to the test data AllTrainers.ThisTrainer = TestItem; //add the record PrimaryKey = AllTrainers.Add(); //set the primary key of the test data TestItem.TrainerID = PrimaryKey; //find the record AllTrainers.ThisTrainer.Find(PrimaryKey); //delete the record AllTrainers.Delete(); //now find the record Boolean Found = AllTrainers.ThisTrainer.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void FullNamePropertyOK() { clsTrainer ATrainer = new clsTrainer(); string name = "Robert Smith"; ATrainer.FullName = name; Assert.AreEqual(ATrainer.FullName, name); }
public void GenderPropertyOK() { clsTrainer ATrainer = new clsTrainer(); string male = "Male"; ATrainer.Gender = male; Assert.AreEqual(ATrainer.Gender, male); }
public void EmailPropertyOK() { clsTrainer ATrainer = new clsTrainer(); string email = "*****@*****.**"; ATrainer.EmailAddress = email; Assert.AreEqual(ATrainer.EmailAddress, email); }
public void InstanceOK() { //create and instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //test to see that it exists Assert.IsNotNull(ATrainer); }
public void fullNameContainsSpace() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String fullName = "AAAAAAAAAAAAAAAAAAAA"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreNotEqual(Error, ""); }
public void fullNameMaxMinusOne() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String fullName = "AAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAA"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreEqual(Error, ""); }
public void genderLowerCaseFemale() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String gender = "female"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreEqual(Error, ""); }
public void emailMaxBoundary() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String email = "*****@*****.**"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreEqual(Error, ""); }
public void emailExtremeMax() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String email = "*****@*****.**"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreNotEqual(Error, ""); }
public void genderNoGender() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String gender = ""; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreNotEqual(Error, ""); }
public void genderMinBoundary() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String gender = "Male"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreEqual(Error, ""); }
public void emailMinPlusOne() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String email = "*****@*****.**"; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreEqual(Error, ""); }
public void dateOfBirthNotBlank() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; //todays date + 100years String dateOfBirth = ""; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreNotEqual(Error, ""); }
public void fullNameExtremeMax() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; String fullName = ""; fullName = fullName.PadRight(100, 'A') + " "; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); Assert.AreNotEqual(Error, ""); }
public void dateOfBirthExtremeMax() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; string TestDate; //todays date + 100years TestDate = DateTime.Now.Date.AddYears(100).ToString(); Error = ATrainer.Valid(fullName, gender, TestDate, email); Assert.AreNotEqual(Error, ""); }
public void dateOfBirthMaxBoundary() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; string TestDate; //todays date - 18 Years should be accepted TestDate = DateTime.Now.Date.AddYears(-18).ToString(); Error = ATrainer.Valid(fullName, gender, TestDate, email); Assert.AreEqual(Error, ""); }
public void dateOfBirthMaxPlusOne() { clsTrainer ATrainer = new clsTrainer(); String Error = ""; string TestDate; //todays date - (18years - 1 day) shouldnt be accepted TestDate = DateTime.Now.Date.AddYears(-18).AddDays(1).ToString(); Error = ATrainer.Valid(fullName, gender, TestDate, email); Assert.AreNotEqual(Error, ""); }
protected void btnView_Click(object sender, EventArgs e) { //create a new instance of clsTrainer clsTrainer ATrainer = new clsTrainer(); //capture all data for validation string fullName = txtFullname.Text; string gender = txtGender.Text; string dateOfBirth = txtDateOfBirth.Text; string email = txtEmail.Text; //variable to store error messages string Error = ""; Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); if (Error == "") { //capture all the data ATrainer.EmailAddress = email; ATrainer.TrainerID = TrainerID; ATrainer.FullName = fullName; ATrainer.DateOfBirth = Convert.ToDateTime(dateOfBirth); ATrainer.Gender = gender; ATrainer.Retrained = chkRetrained.Checked; //create a new instance of the trainer collection clsTrainerCollection AllTrainers = new clsTrainerCollection(); //if this is a new record i.e. Trainer ID = -1 then add the data if (TrainerID == -1) { //set the ThisTrainer property AllTrainers.ThisTrainer = ATrainer; //add the new record AllTrainers.Add(); } else //otherwise it must be an update { //find the record to update AllTrainers.ThisTrainer.Find(TrainerID); //set the ThisTrainer property AllTrainers.ThisTrainer = ATrainer; //update the record AllTrainers.Update(); } //redirect back to the listpage Response.Redirect("DefaultTrainer.aspx"); } else { lblError.Text = Error; } }
public void ValidMethodOK() { //create an instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //string variable to store any error message String Error = ""; //invoke the method Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); //test to see that hte result is correct Assert.AreEqual(Error, ""); }
public void FindMethodOK() { //create an instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //boolean variable to store the result of the validaiton Boolean Found = false; //create some test data to use with the method int TestTrainerID = 2; //invoke the method Found = ATrainer.Find(TestTrainerID); }
public void RetrainedPropertyOK() { //create an instance of the class we weant to create clsTrainer ATrainer = new clsTrainer(); //create the test data to the property Boolean TestData = true; //assign the data to the property ATrainer.Retrained = TestData; //test to see that the two values are the same Assert.AreEqual(ATrainer.Retrained, TestData); }
public void DatePropertyOK() { //create an instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //create some test data to assign to the property DateTime TestData = DateTime.Now.Date; //assign the data to the property ATrainer.DateOfBirth = TestData; //test to see that the two values are the same Assert.AreEqual(ATrainer.DateOfBirth, TestData); }
public void TrainedIDPropertyOK() { //create an instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //create some test data to assign to the property int testID = 2; //assign the data to the property ATrainer.TrainerID = testID; //test to see that the two values are the same Assert.AreEqual(ATrainer.TrainerID, testID); }
public void TestEmailAddressFound() { clsTrainer ATrainer = new clsTrainer(); Boolean Found = false; Boolean OK = true; Int32 TestTrainerID = 2; Found = ATrainer.Find(TestTrainerID); if (ATrainer.EmailAddress != "*****@*****.**") { OK = false; } Assert.IsTrue(OK); }
public void TestRetrainedFound() { clsTrainer ATrainer = new clsTrainer(); Boolean Found = false; Boolean OK = true; Int32 TestTrainerID = 2; Found = ATrainer.Find(TestTrainerID); if (ATrainer.Retrained != true) { OK = false; } Assert.IsTrue(OK); }
public void TestFullNameFound() { clsTrainer ATrainer = new clsTrainer(); Boolean Found = false; Boolean OK = true; Int32 TestTrainerID = 2; Found = ATrainer.Find(TestTrainerID); if (ATrainer.FullName != "Tony Gunn") { OK = false; } Assert.IsTrue(OK); }
public void fullNameExtremeMin() { //create an instance of the class we want to create clsTrainer ATrainer = new clsTrainer(); //string variable to store any error message String Error = ""; //create some test data to pass to the method String fullName = ""; //should fail //invoke the method Error = ATrainer.Valid(fullName, gender, dateOfBirth, email); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }