public void TestValidMethod() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, LastRestock); }
protected void btnSubmit_Click(object sender, EventArgs e) { // create brand instance clsBrand Brand = new clsBrand(); // retreive field values string BrandName = tbName.Text; string TopProduct = dropTop.SelectedValue; string LatestProduct = dropLatest.SelectedValue; string LastRestock = cdrRestock.SelectedDate.ToString(); // avgPrice property needs to be calculated from a mean of a brand's products //store Brand in session object // if valid passes string ErrorMsg = ""; ErrorMsg = Brand.Valid(BrandName, TopProduct, LatestProduct, LastRestock); if (ErrorMsg == "") { // capture brand id Brand.BrandID = BrandID; Brand.BrandName = BrandName; Brand.TopProduct = int.Parse(TopProduct); Brand.LatestProduct = int.Parse(LatestProduct); Brand.LastRestock = Convert.ToDateTime(LastRestock); Brand.IsListed = cbList.Checked; // create a collection instance clsBrandCollection BrandList = new clsBrandCollection(); //add if (Brand.BrandID == -1) { // set ThisBrand BrandList.ThisBrand = Brand; // add record BrandList.Add(); } // otherwise we update else { BrandList.ThisBrand.Find(BrandID); // set ThisAddress BrandList.ThisBrand = Brand; // update BrandList.Update(); } // redirect back to list Response.Redirect("BrandsList.aspx"); } else { lblValidateError.Visible = true; lblValidateError.Text = ErrorMsg; } }
public void TestValidBrandNameMinLessOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; // invoke Valid() with 1 character for BrandName ErrorMsg = brand.Valid("", TopProduct, LatestProduct, LastRestock); // Check the error message matches expected result (error) Assert.AreEqual(ErrorMsg, "You must enter a brand name.<br />"); }
public void TestValidLastRestockMinPlusOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; string MinPlusOne = "01/01/2001"; ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, MinPlusOne); Assert.AreEqual(ErrorMsg, ""); }
public void TestValidLastRestockMin() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; string Min = "31/12/2000"; ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, Min); // should accept min value Assert.AreEqual(ErrorMsg, ""); }
public void TestValidLastRestockMinLessOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; string MinMinusOne = "30/12/2000"; ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, MinMinusOne); Assert.AreEqual(ErrorMsg, "Please enter a more recent date (after 31-12-2000).<br />"); }
public void TestValidBrandNameMaxAddOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; // invoke Valid() with 1 character for BrandName string maxAddOne = "heres a str that should be exactly 51 characters..."; ErrorMsg = brand.Valid(maxAddOne, TopProduct, LatestProduct, LastRestock); // Check the error message matches expected result (no error) Assert.AreEqual(ErrorMsg, "Your brand name is too long. Must be fewer than 50 characters long.<br />"); }
public void TestValidBrandNameMid() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; // invoke Valid() with 1 character for BrandName string mid = "this one is 25 chars(mid)"; ErrorMsg = brand.Valid(mid, TopProduct, LatestProduct, LastRestock); // Check the error message matches expected result (no error) Assert.AreEqual(ErrorMsg, ""); }
public void TestValidBrandNameMax() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; // invoke Valid() with 1 character for BrandName string max = "heres a str that should be exactly 50 characters.."; ErrorMsg = brand.Valid(max, TopProduct, LatestProduct, LastRestock); // Check the error message matches expected result (no error) Assert.AreEqual(ErrorMsg, ""); }
public void TestValidLastRestockExtremeMax() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; DateTime TestDate = DateTime.Today.AddYears(50); // extreme test data string ExtremeMax = TestDate.ToString(); ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, ExtremeMax); // Error message expected Assert.AreEqual(ErrorMsg, "Date cannot be in the future.<br />"); }
public void TestValidLastRestockMaxPlusOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; DateTime TestDate = DateTime.Today.AddDays(1); // tomorrow string MaxPlusOne = TestDate.ToString(); ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, MaxPlusOne); // Error message expected Assert.AreEqual(ErrorMsg, "Date cannot be in the future.<br />"); }
public void TestValidLastRestockMax() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; DateTime TestDate = DateTime.Today; // today string Max = TestDate.ToString(); ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, Max); // no error msg Assert.AreEqual(ErrorMsg, ""); }
public void TestValidLastRestockMaxLessOne() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; DateTime TestDate = DateTime.Today.AddDays(-1); // yesterday string MaxLessOne = TestDate.ToString(); ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, MaxLessOne); // no error msg Assert.AreEqual(ErrorMsg, ""); }
public void TestValidLastRestockExtremeMin() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; DateTime TestDate = DateTime.Today.AddYears(-50); string ExtremeMin = TestDate.ToString(); ErrorMsg = brand.Valid(BrandName, TopProduct, LatestProduct, ExtremeMin); Assert.AreEqual(ErrorMsg, "Please enter a more recent date (after 31-12-2000).<br />"); }
public void TestValidBrandNameExtremeMax() { clsBrand brand = new clsBrand(); String ErrorMsg = ""; // invoke Valid() with 1 character for BrandName string extremeMax = "Extreme Max String (200) Extreme Max String (200) Extreme Max String (200) " + "Extreme Max String (200) Extreme Max String (200) Extreme Max String (200) Extreme Max String (200) " + "Extreme Max String (200) "; ErrorMsg = brand.Valid(extremeMax, TopProduct, LatestProduct, LastRestock); // Check the error message matches expected result (no error) Assert.AreEqual(ErrorMsg, "Your brand name is too long. Must be fewer than 50 characters long.<br />"); }