public void ValidMethodOK() { ClsCar car = new ClsCar(); String Error = ""; Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price); Assert.AreEqual(Error, ""); }
protected void btnOK_Click(object sender, EventArgs e) { ClsCar ACar = new ClsCar(); String NumberPlate = txtNumberPlate.Text; String Make = txtMake.Text; String Model = txtModel.Text; String Colour = txtColour.Text; String Description = txtDescription.Text; String Price = txtPrice.Text; String OfficeCode = txtOfficeCode.Text; String Error = ""; Error = ACar.Valid(NumberPlate, Make, Model, Description, Colour, Price); if (Error == "") { ACar.NumberPlate = NumberPlate; ACar.Make = Make; ACar.Model = Model; ACar.Colour = Colour; ACar.Description = Description; ACar.Price = Convert.ToInt32(Price); ACar.OfficeCode = Convert.ToInt32(OfficeCode); ClsCarCollection CarList = new ClsCarCollection(); //if this is a new record i.e. NumberPlate != -1 then add the data if (CarID == -1) { //set the ThisCar Property CarList.ThisCar = ACar; //add the new record CarList.Add(); } //otherwise it must be an update else { //find the record to update CarList.ThisCar.Find(CarID); //set the ThisCar property CarList.ThisCar = ACar; //update the record CarList.Update(); } //redirect back to thte list page Response.Redirect("CarList.aspx"); } else { //display the error message lblError.Text = Error; } }
public void PriceMinPlusOne() { ClsCar car = new ClsCar(); //error variable stores any error messages String Error = ""; //test data to pass to method String Price = "00"; // this should be ok //invoke the method Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price); //test to see if the result is correct Assert.AreEqual(Error, ""); }
public void ColourMinLessOne() { ClsCar car = new ClsCar(); //error variable stores any error messages String Error = ""; //test data to pass to method String Colour = ""; //should trigger an error //invoke the method Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price); //test to see if the result is correct Assert.AreNotEqual(Error, ""); }
public void ColourExtremeMax() { ClsCar car = new ClsCar(); //error variable stores any error messages String Error = ""; //test data to pass to method String Colour = ""; Colour = Colour.PadRight(500, 'a'); // this should fail //invoke the method Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price); //test to see if the result is correct Assert.AreNotEqual(Error, ""); }
public void DescriptionMid() { ClsCar car = new ClsCar(); //error variable stores any error messages String Error = ""; //test data to pass to method String Description = ""; // this should be ok Description = Description.PadRight(100, 'a'); //invoke the method Error = car.Valid(NumberPlate, Make, Model, Description, Colour, Price); //test to see if the result is correct Assert.AreEqual(Error, ""); }