protected void btnOk_Click(object sender, EventArgs e) { //create a new instance of clsGame clsGame AGame = new clsGame(); //capture the data for each field string GameId = txtGameId.Text; string GameTitle = txtGameTitle.Text; string GameDescription = txtGameDescription.Text; string ReleaseDate = txtReleaseDate.Text; string Price = txtPrice.Text; string StockQuantity = txtStockQuantity.Text; string Error = ""; //Validate the data Error = AGame.Valid(GameId, GameTitle, GameDescription, Price, ReleaseDate, StockQuantity); if (Error == "") { //capture the game Id AGame.GameId = Convert.ToInt32(txtGameId.Text); AGame.GameTitle = txtGameTitle.Text; AGame.GameDescription = txtGameDescription.Text; AGame.ReleaseDate = Convert.ToDateTime(txtReleaseDate.Text).Date; AGame.Price = Convert.ToDecimal(txtPrice.Text); AGame.StockQuantity = Convert.ToInt32(txtStockQuantity.Text); AGame.InStock = chkInStock.Checked; //create a new instance of the game collection clsGameCollection GameList = new clsGameCollection(); //if this is a new record i.e. GameId = -1 then add the data if (this.GameId == -1) { //set the ThisGame property GameList.ThisGame = AGame; //add the new record GameList.Add(); } //Otherwise it must be an update else { //find the record to update GameList.ThisGame.Find(Convert.ToInt32(GameId)); //set the ThisGame property GameList.ThisGame = AGame; //update the record GameList.Update(); } //redirect back to the listpage Response.Redirect("StockList.aspx"); //store the attributes in the session object //Session["AGame"] = AGame; //redirects to the viewer page //Response.Redirect("StockViewer.aspx"); } else { //Display the error message lblError.Text = Error; } }
public void AddMethodOK() { //Create an instance if the class we want to create clsGameCollection AllGames = new clsGameCollection(); //Create the item of test data clsGame TestItem = new clsGame(); //var to store the primary key Int32 PrimaryKey = 0; //Set its properties TestItem.GameId = 1; TestItem.GameTitle = "A Game Name"; TestItem.GameDescription = "A Game Description"; TestItem.ReleaseDate = DateTime.Now.Date; TestItem.Price = 20; TestItem.StockQuantity = 200; TestItem.InStock = true; //set ThisGame to the test data AllGames.ThisGame = TestItem; //add the record PrimaryKey = AllGames.Add(); //set the primary key of the test data TestItem.GameId = PrimaryKey; //find the record AllGames.ThisGame.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllGames.ThisGame, TestItem); }
public void GameIDPropertyOK() { clsGame aGame = new clsGame(); int testId = 1; aGame.GameId = testId; Assert.AreEqual(aGame.GameId, testId); }
public void DatePublishedExtremeMax() { clsGame aGame = new clsGame(); string TestDate = DateTime.Now.Date.AddYears(50).ToString(); string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreNotEqual(Error, ""); }
public void StockQuantityOK() { clsGame AGame = new clsGame(); Int32 TestData = 1000; AGame.StockQuantity = TestData; Assert.AreEqual(AGame.StockQuantity, TestData); }
public void ValidMethodOK() { clsGame AGame = new clsGame(); string Error = ""; Error = AGame.Valid(GameId, GameTitle, GameDescription, Price, ReleaseDate, StockQuantity); Assert.AreEqual(Error, ""); }
public void GameTitleOK() { clsGame AGame = new clsGame(); string TestData = "A Game Title"; AGame.GameTitle = TestData; Assert.AreEqual(AGame.GameTitle, TestData); }
public void ReleaseDateOK() { clsGame AGame = new clsGame(); DateTime TestData = DateTime.Now.Date; AGame.ReleaseDate = TestData; Assert.AreEqual(AGame.ReleaseDate, TestData); }
public void DiscountMaxLessOne() { clsGame aGame = new clsGame(); string TestDiscount = (99).ToString(); string Error = aGame.Valid(GameTitle, Price, TestDiscount, DatePublished); Assert.AreEqual(Error, ""); }
public void ActivePropertyOK() { clsGame aGame = new clsGame(); bool testActive = false; aGame.Active = testActive; Assert.AreEqual(aGame.Active, testActive); }
public void PriceInvalidType() { clsGame aGame = new clsGame(); string TestPrice = "Jeff"; string Error = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished); Assert.AreNotEqual(Error, ""); }
public void PricePropertyOK() { clsGame aGame = new clsGame(); double testPrice = 12.20; aGame.Price = testPrice; Assert.AreEqual(aGame.Price, testPrice); }
public void PriceMaxPlusOne() { clsGame aGame = new clsGame(); string TestPrice = (101.00).ToString(); string Error = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished); Assert.AreNotEqual(Error, ""); }
public void GameTitlePropertyOK() { clsGame aGame = new clsGame(); string testTitle = "Test Title"; aGame.GameTitle = testTitle; Assert.AreEqual(aGame.GameTitle, testTitle); }
public void PriceExtremeMin() { clsGame aGame = new clsGame(); string TestPrice = (-500.00).ToString(); string Error = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished); Assert.AreNotEqual(Error, ""); }
public void DatePublishedInvalidType() { clsGame aGame = new clsGame(); string TestDate = "Test21"; string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreNotEqual(Error, ""); }
public void DiscountExtremeMax() { clsGame aGame = new clsGame(); string TestDiscount = (500).ToString(); string Error = aGame.Valid(GameTitle, Price, TestDiscount, DatePublished); Assert.AreNotEqual(Error, ""); }
public void DatePublishedPropertyOK() { clsGame aGame = new clsGame(); DateTime testDate = new DateTime(2021, 02, 22); aGame.DatePublished = testDate; Assert.AreEqual(aGame.DatePublished, testDate); }
public void DatePublishedExtremeMin() { clsGame aGame = new clsGame(); string TestDate = (new DateTime(1960, 06, 21)).ToString(); string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreNotEqual(Error, ""); }
public void GameIdOK() { clsGame AGame = new clsGame(); int TestData = 1; AGame.GameId = TestData; Assert.AreEqual(AGame.GameId, TestData); }
public void DatePublishedMinLessOne() { clsGame aGame = new clsGame(); string TestDate = (new DateTime(1989, 12, 31)).ToString(); string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreNotEqual(Error, ""); }
public void InStockOK() { clsGame AGame = new clsGame(); Boolean TestData = true; AGame.InStock = TestData; Assert.AreEqual(AGame.InStock, TestData); }
public void DiscountPropertyOK() { clsGame aGame = new clsGame(); int testDiscount = 20; aGame.Discount = testDiscount; Assert.AreEqual(aGame.Discount, testDiscount); }
public void PriceOK() { clsGame AGame = new clsGame(); decimal TestData = 60; AGame.Price = TestData; Assert.AreEqual(AGame.Price, TestData); }
public void InstanceOK() { //create an instance of the class that we want to create clsGame AGame = new clsGame(); //test to see if the class works or not Assert.IsNotNull(AGame); }
public void GameDescriptionOK() { clsGame AGame = new clsGame(); string TestData = "A description of the game is that it is a game"; AGame.GameDescription = TestData; Assert.AreEqual(AGame.GameDescription, TestData); }
public void ValidMethodOK() { clsGame aGame = new clsGame(); string Error; Error = aGame.Valid(GameTitle, Price, Discount, DatePublished); Assert.AreEqual(Error, ""); }
public void DatePublishedMid() { clsGame aGame = new clsGame(); string TestDate = (new DateTime(2001, 03, 29)).ToString(); string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreEqual(Error, ""); }
public void GameTitleMinPlusOne() { clsGame aGame = new clsGame(); string TestTitle = "12"; string Error = aGame.Valid(TestTitle, Price, Discount, DatePublished); Assert.AreEqual(Error, ""); }
public void DatePublishedMaxPlusOne() { clsGame aGame = new clsGame(); string TestDate = DateTime.Now.Date.AddDays(1).ToString(); string Error = aGame.Valid(GameTitle, Price, Discount, TestDate); Assert.AreNotEqual(Error, ""); }
public void SetDetails(clsGame prGame) { _Game = prGame; updateForm(); ShowDialog(); }