public void DeleteMethodOK() { //create an instance of the class clsTrainersCollection AllTrainers = new clsTrainersCollection(); //create the item of test data clsTrainers TestItem = new clsTrainers(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.Brand = "Adidas"; TestItem.Name = "Originals"; TestItem.Colour = "White"; TestItem.Size = 2; TestItem.Price = 9.89M; TestItem.DateAdded = DateTime.Now.Date; TestItem.InStock = true; //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 ListAndCountOK() { //create an instance of the class clsTrainersCollection AllTrainers = new clsTrainersCollection(); //create some test data to assign to the property List <clsTrainers> TestList = new List <clsTrainers>(); //add an item to the list //create the item of test data clsTrainers TestItem = new clsTrainers(); //set the properties of the test object TestItem.Brand = "Adidas"; TestItem.Name = "Originals"; TestItem.Colour = "White"; TestItem.Size = 2; TestItem.Price = 9.89M; TestItem.DateAdded = DateTime.Now.Date; TestItem.InStock = true; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllTrainers.TrainersList = TestList; //test to see that it exists Assert.AreEqual(AllTrainers.Count, TestList.Count); }
protected void btnFind_Click(object sender, EventArgs e) { //create an instance of the trainers class clsTrainers ATrainer = new clsTrainers(); //variable to store the primary key Int32 TrainerID; //variable to store the result of the find operation Boolean Found = false; //get the primary key entered by the user TrainerID = Convert.ToInt32(txtTrainerID.Text); //find the record Found = ATrainer.Find(TrainerID); //if found if (Found == true) { //display the values of the properties in the form txtBrand.Text = ATrainer.Brand; txtName.Text = ATrainer.Name; ddlColour.Text = ATrainer.Colour; txtSize.Text = ATrainer.Size.ToString(); txtPrice.Text = ATrainer.Price.ToString(); txtDateAdded.Text = ATrainer.DateAdded.ToString(); } else { lblError.Text = "Trainer not found"; } }
public void AddMethodOK() { //create an instance of the class clsTrainersCollection AllTrainers = new clsTrainersCollection(); //create the item of test data clsTrainers TestItem = new clsTrainers(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.Brand = "Adidas"; TestItem.Name = "Originals"; TestItem.Colour = "White"; TestItem.Size = 2; TestItem.Price = 9.89M; TestItem.DateAdded = DateTime.Now.Date; TestItem.InStock = true; //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); //test to see that the two values are the same Assert.AreEqual(AllTrainers.ThisTrainer, TestItem); }
public void InstanceOK() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //test to see that it exists Assert.IsNotNull(ATrainer); }
public void PriceOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //test data to assign to the property Decimal TestData = 50; //test to see the two values are the same Assert.AreNotEqual(TestData, ATrainer.Price); }
public void TrainerIDOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); // create test data to assign to the property Int32 TestData = 1; //assign data to the property ATrainer.TrainerID = TestData; //test to see the two values are the same Assert.AreEqual(TestData, ATrainer.TrainerID); }
public void ValidMethodOK() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void InStockOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //create some test data to assign to the property Boolean TestData = true; //assign the data to the property ATrainer.InStock = TestData; //test to see the two values are the same Assert.AreEqual(TestData, ATrainer.InStock); }
public void DateAddedOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //test data to assign to the property DateTime TestData = DateTime.Now.Date; //assign data to the property ATrainer.DateAdded = TestData; //test to see the two values are the same Assert.AreEqual(TestData, ATrainer.DateAdded); }
public void ColourOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //test data to assign to the property string TestData; TestData = "Black"; //assign data to the property ATrainer.Colour = TestData; //test to see the two values are the same Assert.AreEqual(TestData, ATrainer.Colour); }
public void FoundOK() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //test data to store the result of the search Boolean Found = false; //create some test data to use with the method Int32 TrainerID = 2; //invoke the method Found = ATrainer.Find(TrainerID); Assert.IsTrue(Found); }
public void ColourMinPlusOne() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string Colour = "aa"; //this should be okay //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void DateAddedInvalidData() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //set the dateAdded to a non date value string DateAdded = "This is not a date"; //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void SizeInvalidData() { //create instance of the class clsTrainers ATrainer = new clsTrainers(); //string to store error message String Error = ""; //set the date added to non date value String Size = "Value entered is not a number!"; //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void ColourMaxExtreme() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string Colour = ""; Colour = Colour.PadRight(100, 'N'); //this should fail //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
protected void Page_Load(object sender, EventArgs e) { //create a new instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //get the data from the session object ATrainer = (clsTrainers)Session["ATrainer"]; //display the properties of this entry Response.Write(ATrainer.Brand); Response.Write(ATrainer.Name); Response.Write(ATrainer.Colour); Response.Write(ATrainer.Size); Response.Write(ATrainer.Price); Response.Write(ATrainer.DateAdded); Response.Write(ATrainer.InStock); }
public void SizeMinLessOne() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //create some test data to pass to the method Int32 TestSize = 0; //this should trigger an error //convert the size variable to a string variable string Size = TestSize.ToString(); //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void PriceMin() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //create some test data to pass to the method Decimal TestPrice = 0.01M; //this should pass //convert the size variable to a string variable string Price = TestPrice.ToString(); //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void DateAddedMin() { //create an instance of the class we want to create clsTrainers ATrainer = new clsTrainers(); //string variable to store any error message String Error = ""; //create some test data to pass to the method DateTime TestData; //set the date to todays date TestData = DateTime.Now.Date; //convert the date variable to a string variable string DateAdded = TestData.ToString(); //invoke the method Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void ThisTrainersPropertyOK() { //create an instance of the class clsTrainersCollection AllTrainers = new clsTrainersCollection(); //create some test data to assign to the property clsTrainers TestTrainers = new clsTrainers(); //set the properties of the test object TestTrainers.Brand = "Adidas"; TestTrainers.Name = "Originals"; TestTrainers.Colour = "White"; TestTrainers.Size = 2; TestTrainers.Price = 9.89M; TestTrainers.DateAdded = DateTime.Now.Date; TestTrainers.InStock = true; //assign the data to the property AllTrainers.ThisTrainer = TestTrainers; //test to see that it exists Assert.AreEqual(AllTrainers.ThisTrainer, TestTrainers); }
public void TestInStockFound() { //create an instance of the class clsTrainers clsTrainers ATrainer = new clsTrainers(); //test data to store the result of the search Boolean Found = false; //boolean variable to record if data is OK Boolean OK = true; //create some test data to use with the method Int32 TrainerID = 2; //invoke the method Found = ATrainer.Find(TrainerID); //check the property if (ATrainer.InStock != true) { OK = false; } //test to see that the result is correct Assert.IsTrue(OK); }
public void UpdateMethodOK() { //create an instance of the class clsTrainersCollection AllTrainers = new clsTrainersCollection(); //create the item of test data clsTrainers TestItem = new clsTrainers(); //var to store the primary key Int32 PrimaryKey = 0; //set the properties of the test object TestItem.Brand = "Adidas"; TestItem.Name = "Originals"; TestItem.Colour = "White"; TestItem.Size = 2; TestItem.Price = 9.89M; TestItem.DateAdded = DateTime.Now.Date; TestItem.InStock = true; //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; //modify the test data TestItem.Brand = "Nike"; TestItem.Name = "AirMax"; TestItem.Colour = "Black"; TestItem.Size = 7; TestItem.Price = 75.99M; TestItem.DateAdded = DateTime.Now.Date; TestItem.InStock = false; //set the record based on the new test data AllTrainers.ThisTrainer = TestItem; //update the record AllTrainers.Update(); //find the record AllTrainers.ThisTrainer.Find(PrimaryKey); //test to see ThisTrainer matches the test data Assert.AreEqual(AllTrainers.ThisTrainer, TestItem); }
protected void btnOK_Click(object sender, EventArgs e) { //create a new instance of clsTrainers clsTrainers ATrainer = new clsTrainers(); //capture the properties string Brand = txtBrand.Text; string Name = txtName.Text; string Colour = ddlColour.Text; string Size = txtSize.Text; string Price = txtPrice.Text; string DateAdded = txtDateAdded.Text; //variable to store any error messages string Error = ""; //validate the data Error = ATrainer.Valid(Brand, Name, Colour, Size, Price, DateAdded); if (Error == "") { //capture the properties ATrainer.Brand = Brand; ATrainer.Name = Name; ATrainer.Colour = Colour; ATrainer.Size = Convert.ToInt32(Size); ATrainer.Price = Convert.ToDecimal(Price); ATrainer.DateAdded = Convert.ToDateTime(DateAdded); //store the trainers in the session object Session["ATrainer"] = ATrainer; //redirect to the viewer page Response.Redirect("TrainerViewer.aspx"); } else { //display an error message lblError.Text = Error; } }