public void ValidMethodOK() { clscustomer Acustomer = new clscustomer(); String Error = ""; Error = Acustomer.Valid(Name, Email, DOB, Address); Assert.AreEqual(Error, ""); }
public void AddressMinPlusOne() { //create an instance of the class we want to create clscustomer Acustomer = new clscustomer(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string Address = "aa"; //this should be ok //invoke the method Error = Acustomer.Valid(Name, Email, DOB, Address); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void DOBInvalidData() { //create an instance of the class we want to create clscustomer Acustomer = new clscustomer(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string DOB = "This is not a date!"; //this should fail Name = Name.PadRight(500, 'a'); //this should fail //invoke the method Error = Acustomer.Valid(Name, Email, DOB, Address); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void EmailMaxPlusOne() { //create an instance of the class we want to create clscustomer Acustomer = new clscustomer(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string Email = ""; //this should fail Email = Email.PadRight(51, 'a'); //invoke the method Error = Acustomer.Valid(Name, Email, DOB, Address); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
protected void btnOK_Click(object sender, EventArgs e) { //create a new instance of clscustomer clscustomer Acustomer = new clscustomer(); //capture the details string Name = txtName.Text; string Email = txtEmail.Text; string DOB = txtDOB.Text; string Address = txtAddress.Text; string Error = ""; Error = Acustomer.Valid(Name, Email, DOB, Address); if (Error == "") { Acustomer.CustomerNo = Convert.ToInt32(CustomerNo); Acustomer.Name = Name; Acustomer.Email = Email; Acustomer.DOB = Convert.ToDateTime(DOB); Acustomer.Address = Address; Acustomer.Registered = chkRegistered.Checked; clsCustomerCollection CustomerList = new clsCustomerCollection(); if (CustomerNo == -1) { CustomerList.ThisCustomer = Acustomer; CustomerList.Add(); } else { CustomerList.ThisCustomer.Find(CustomerNo); CustomerList.ThisCustomer = Acustomer; CustomerList.Update(); } Response.Redirect("CustomerList.aspx"); //CustomerList.ThisCustomer = Acustomer; //CustomerList.Add(); //Response.Redirect("CustomerList.aspx"); } else { lblerror.Text = Error; } }
public void DOBMax() { //create an instance of the class we want to create clscustomer Acustomer = new clscustomer(); //string variable to store any error message String Error = ""; //create a variable to store the test date data DateTime TestDate; //set the date totodays date TestDate = DateTime.Now.Date; //convert the date variable to a string variable string DOB = TestDate.ToString(); //invoke the method Error = Acustomer.Valid(Name, Email, DOB, Address); //test to see that the result is correct Assert.AreEqual(Error, ""); }