protected void ButtonOK_Click2(object sender, EventArgs e) { //create a new instance of ClsStock ClsStock AnStock = new ClsStock(); //capture the product description string ProductDescript = txtProductDescript.Text; //capture the price of the product string Cost = txtCost.Text; //capture the date the product was added string DateAdded = txtDateAdded.Text; //capture the stock number string StockNo = txtStockNo.Text; //variable to store any error messages string Error = ""; //validate the data Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded); if (Error == "") { //capture the product ID AnStock.StockNo = StockNo; //capture the produt description AnStock.ProductDescript = ProductDescript; //capture the cost AnStock.Cost = Cost; //capture the date the stock was added AnStock.DateAdded = Convert.ToDateTime(DateAdded); //capture the stock quantity AnStock.StockNo = StockNo; //capture the in stock AnStock.InStck = chkInStck.Checked; //create a new instance of the stock collection clsStockCollection StockList = new clsStockCollection(); if (ProductNo == -1) { //set the ThisStock property StockList.ThisStock = AnStock; //add the new record StockList.Add(); } //otherwise it must be an updte else { //find the record to update StockList.ThisStock.Find(ProductNo); //set the ThisStock property StockList.ThisStock = AnStock; //update the record StockList.Update(); } //redirect to the viewer page Response.Write("StockNoViewer.aspx"); } else { //display the error message lblError.Text = Error; } }
public void AddMethodStockOK() { ClsStockCollection AllAddresses = new ClsStockCollection(); ClsStock TestItem = new ClsStock(); Int32 PrimaryKey = 0; TestItem.ShoeID = 1; TestItem.Name = "AirForce"; TestItem.Release = DateTime.Now.Date; TestItem.QuantityStock = 1; TestItem.PriceStock = 1; TestItem.Size = 1; AllAddresses.ThisStock = TestItem; PrimaryKey = AllAddresses.Add(); TestItem.ShoeID = PrimaryKey; AllAddresses.ThisStock.Find(PrimaryKey); Assert.AreEqual(AllAddresses.ThisAddressList, TestItem); }
public void ListAndCountOK() { //create an instance of the class we want to create clsStockCollection AllStock = new clsStockCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <ClsStock> TestList = new List <ClsStock>(); //add an item to the list //create the item of test data ClsStock TestItem = new ClsStock(); //set its properties TestItem.ProductNo = 5; TestItem.ProductDescript = "Liverpool Shirt"; TestItem.Cost = 69; TestItem.DateAdded = DateTime.Now.Date; TestItem.StockNo = 50; TestItem.InStck = true; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllStock.StockList = TestList; //test to see that the two values are the same Assert.AreEqual(AllStock.Count, TestList.Count); }
public void ReleaseExtMaz() { try { ClsStock Stock = new ClsStock(); String Error = ""; DateTime TestDate; TestDate = DateTime.Now.Date; TestDate = TestDate.AddYears(100); string DateAdded = TestDate.ToString(); Error = Stock.Valid(Name, Release, Quantity, Price, Size); Assert.AreEqual(Error, ""); } catch (Exception) { } }
public void TestReleaseFound() { try { ClsStock Stock = new ClsStock(); Boolean Found = false; Boolean OK = true; Int32 ShoeID = 2; Found = Stock.Find(ShoeID); if (Stock.Release != Convert.ToDateTime("22/02/2020")) { OK = false; } Assert.IsTrue(OK); } catch (Exception ex) { } }
public void TestSizeFound() { try { ClsStock Stock = new ClsStock(); Boolean Found = false; Boolean OK = true; Int32 ShoeID = 2; Found = Stock.Find(ShoeID); if (Stock.Size != 5) { OK = false; } Assert.IsTrue(OK); } catch (Exception ex) { } }
public void AddMethodOK() { //create an instance of the class we want to create clsStockCollection AllStock = new clsStockCollection(); //create the item of test data ClsStock TestItem = new ClsStock(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.InStck = true; TestItem.ProductNo = 1; TestItem.ProductDescript = "Liverpool Shirt"; TestItem.Cost = 59; TestItem.StockNo = 50; TestItem.DateAdded = DateTime.Now.Date; //set ThisStock to the test data AllStock.ThisStock = TestItem; //add the record PrimaryKey = AllStock.Add(); //set the primary key of the test data TestItem.ProductNo = PrimaryKey; //find the record AllStock.ThisStock.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllStock.ThisStock, TestItem); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsStockCollection AllStock = new clsStockCollection(); //create the item of test data ClsStock TestItem = new ClsStock(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.InStck = true; TestItem.ProductNo = 1; TestItem.ProductDescript = "Liverpool Shirt"; TestItem.Cost = 59; TestItem.StockNo = 50; TestItem.DateAdded = DateTime.Now.Date; //set ThisStock to the test data AllStock.ThisStock = TestItem; //add the record PrimaryKey = AllStock.Add(); //set the primary key of the test data TestItem.StockNo = PrimaryKey; //find the record AllStock.ThisStock.Find(PrimaryKey); //delete the record AllStock.Delete(); //now find the record Boolean Found = AllStock.ThisStock.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void InstanceOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //test to see that it exists Assert.IsNotNull(AnStock); }
public void ReleaseOK() { ClsStock Stock = new ClsStock(); DateTime TestData = DateTime.Now.Date; Stock.Release = TestData; Assert.AreEqual(Stock.Release, TestData); }
public void NameOK1() { ClsStock Stock = new ClsStock(); var TestData = "Nike"; Stock.Name = TestData; Assert.AreEqual(Stock.Name, TestData); }
public void ShoeIdOK() { ClsStock Stock = new ClsStock(); int TestData = 1; Stock.ShoeID = TestData; Assert.AreEqual(Stock.ShoeID, TestData); }
public void QuantityStockOK() { ClsStock Stock = new ClsStock(); int TestData = 4; Stock.QuantityStock = TestData; Assert.AreEqual(Stock.QuantityStock, TestData); }
public void PriceStockOK() { ClsStock Stock = new ClsStock(); int TestData = 4; Stock.PriceStock = TestData; Assert.AreEqual(Stock.PriceStock, TestData); }
protected void Page_Load(object sender, EventArgs e) { //create a new instance of ClsStock ClsStock AnStock = new ClsStock(); //get the data from the session object AnStock = (ClsStock)Session["AnStock"]; //display the stock number Response.Write(AnStock.ProductDescript); }
public void SizekOK() { ClsStock Stock = new ClsStock(); int TestData = 10; Stock.Size = TestData; Assert.AreEqual(Stock.Size, TestData); }
public void InStockOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //create some test data to assign to the property Boolean TestData = true; //assign the data to the property AnStock.InStck = TestData; //test to see that the two values are the same Assert.AreEqual(AnStock.InStck, TestData); }
public void StockDateOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //create some test data to assign to the property DateTime TestData = DateTime.Now.Date; //assign the data to the property AnStock.DateAdded = TestData; //test to see that the two values are the same Assert.AreEqual(AnStock.DateAdded, TestData); }
public void StockQuantityOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //create some test data to assign to the property Int32 TestData = 50; //assign the data to the property AnStock.StockNo = TestData; //test to see that the two values are the same Assert.AreEqual(AnStock.StockNo, TestData); }
public void ProductDescriptionOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //create some test data to assign to the property string TestData = "Liverpool Shirt"; //assign the data to the property AnStock.ProductDescript = TestData; //test to see that the two values are the same Assert.AreEqual(AnStock.ProductDescript, TestData); }
public void ValidMethodOK() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //string variable to store any error message String Error = ""; //invoke the method Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void fillcprice() { ClsStock objstock = new ClsStock(); Stock obj = new Stock(); //obj = objstock. if (ddlprod != null) { txtcprice.Text = Convert.ToInt32(obj.Price).ToString(); // txtcstock.Text = Convert.ToInt32(pd.ProductId).ToString(); } }
public void fillcstock(int id) { ClsStock objstock = new ClsStock(); Stock obj = new Stock(); //obj = objstock. if (ddlprod != null) { // txtcstock.Text = txtcstock.Text = Convert.ToInt32(obj.ProductId).ToString(); } }
public void ValidMethodStockOK() { try { ClsStock Stock = new ClsStock(); String Error = ""; Error = Stock.Valid(Name, Release, Quantity, Price, Size); Assert.AreEqual(Error, ""); } catch (Exception) { } }
public void DateAddedInvalidData() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //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 = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded); //test to see that the result is correct Assert.AreNotEqual(Error, ""); }
public void ProductDescriptMid() { //create an instance of the class we want to create ClsStock AnStock = new ClsStock(); //string variable to store any error message String Error = ""; //create some test data to pass to the method string ProductDescript = "aaaa"; //this should be ok //invoke the method Error = AnStock.Valid(ProductDescript, Cost, StockNo, DateAdded); //test to see that the result is correct Assert.AreEqual(Error, ""); }
public void FindMethodOK() { //create ClsStock AnStock = new ClsStock(); //boolean Boolean Found = false; //create Int32 StockNo = 1; //invoke Found = AnStock.Find(StockNo); //test Assert.IsTrue(Found); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ClsStock Stock = new ClsStock(); Stock = (ClsStock)Session["Stock"]; if (Stock != null) { Response.Write(Stock.ShoeID); } } }
protected void Button1_Click(object sender, EventArgs e) { //create a new instance of ClsStock ClsStock AnStock = new ClsStock { //capture the product ID ProductNo = txtProductNo.Test }; //store the stock number in the session object Session["AnStock"] = AnStock; //redirect to the viewer page Response.Redirect("StockNumberViewer.aspx"); }
public void FindMethodStockOK() { try { ClsStock Stock = new ClsStock(); Boolean Found = false; Int32 ShoeID = 2; Found = Stock.Find(ShoeID); Assert.IsTrue(Found); } catch (Exception ex) { } }