コード例 #1
0
    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;
        }
    }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void GameIDPropertyOK()
        {
            clsGame aGame  = new clsGame();
            int     testId = 1;

            aGame.GameId = testId;
            Assert.AreEqual(aGame.GameId, testId);
        }
コード例 #4
0
        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, "");
        }
コード例 #5
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void StockQuantityOK()
        {
            clsGame AGame    = new clsGame();
            Int32   TestData = 1000;

            AGame.StockQuantity = TestData;
            Assert.AreEqual(AGame.StockQuantity, TestData);
        }
コード例 #6
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void ValidMethodOK()
        {
            clsGame AGame = new clsGame();
            string  Error = "";

            Error = AGame.Valid(GameId, GameTitle, GameDescription, Price, ReleaseDate, StockQuantity);
            Assert.AreEqual(Error, "");
        }
コード例 #7
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void GameTitleOK()
        {
            clsGame AGame    = new clsGame();
            string  TestData = "A Game Title";

            AGame.GameTitle = TestData;
            Assert.AreEqual(AGame.GameTitle, TestData);
        }
コード例 #8
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void ReleaseDateOK()
        {
            clsGame  AGame    = new clsGame();
            DateTime TestData = DateTime.Now.Date;

            AGame.ReleaseDate = TestData;
            Assert.AreEqual(AGame.ReleaseDate, TestData);
        }
コード例 #9
0
        public void DiscountMaxLessOne()
        {
            clsGame aGame        = new clsGame();
            string  TestDiscount = (99).ToString();
            string  Error        = aGame.Valid(GameTitle, Price, TestDiscount, DatePublished);

            Assert.AreEqual(Error, "");
        }
コード例 #10
0
        public void ActivePropertyOK()
        {
            clsGame aGame      = new clsGame();
            bool    testActive = false;

            aGame.Active = testActive;
            Assert.AreEqual(aGame.Active, testActive);
        }
コード例 #11
0
        public void PriceInvalidType()
        {
            clsGame aGame     = new clsGame();
            string  TestPrice = "Jeff";
            string  Error     = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished);

            Assert.AreNotEqual(Error, "");
        }
コード例 #12
0
        public void PricePropertyOK()
        {
            clsGame aGame     = new clsGame();
            double  testPrice = 12.20;

            aGame.Price = testPrice;
            Assert.AreEqual(aGame.Price, testPrice);
        }
コード例 #13
0
        public void PriceMaxPlusOne()
        {
            clsGame aGame     = new clsGame();
            string  TestPrice = (101.00).ToString();
            string  Error     = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished);

            Assert.AreNotEqual(Error, "");
        }
コード例 #14
0
        public void GameTitlePropertyOK()
        {
            clsGame aGame     = new clsGame();
            string  testTitle = "Test Title";

            aGame.GameTitle = testTitle;
            Assert.AreEqual(aGame.GameTitle, testTitle);
        }
コード例 #15
0
        public void PriceExtremeMin()
        {
            clsGame aGame     = new clsGame();
            string  TestPrice = (-500.00).ToString();
            string  Error     = aGame.Valid(GameTitle, TestPrice, Discount, DatePublished);

            Assert.AreNotEqual(Error, "");
        }
コード例 #16
0
        public void DatePublishedInvalidType()
        {
            clsGame aGame    = new clsGame();
            string  TestDate = "Test21";
            string  Error    = aGame.Valid(GameTitle, Price, Discount, TestDate);

            Assert.AreNotEqual(Error, "");
        }
コード例 #17
0
        public void DiscountExtremeMax()
        {
            clsGame aGame        = new clsGame();
            string  TestDiscount = (500).ToString();
            string  Error        = aGame.Valid(GameTitle, Price, TestDiscount, DatePublished);

            Assert.AreNotEqual(Error, "");
        }
コード例 #18
0
        public void DatePublishedPropertyOK()
        {
            clsGame  aGame    = new clsGame();
            DateTime testDate = new DateTime(2021, 02, 22);

            aGame.DatePublished = testDate;
            Assert.AreEqual(aGame.DatePublished, testDate);
        }
コード例 #19
0
        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, "");
        }
コード例 #20
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void GameIdOK()
        {
            clsGame AGame    = new clsGame();
            int     TestData = 1;

            AGame.GameId = TestData;
            Assert.AreEqual(AGame.GameId, TestData);
        }
コード例 #21
0
        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, "");
        }
コード例 #22
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void InStockOK()
        {
            clsGame AGame    = new clsGame();
            Boolean TestData = true;

            AGame.InStock = TestData;
            Assert.AreEqual(AGame.InStock, TestData);
        }
コード例 #23
0
        public void DiscountPropertyOK()
        {
            clsGame aGame        = new clsGame();
            int     testDiscount = 20;

            aGame.Discount = testDiscount;
            Assert.AreEqual(aGame.Discount, testDiscount);
        }
コード例 #24
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        public void PriceOK()
        {
            clsGame AGame    = new clsGame();
            decimal TestData = 60;

            AGame.Price = TestData;
            Assert.AreEqual(AGame.Price, TestData);
        }
コード例 #25
0
ファイル: tstGame.cs プロジェクト: KMan97/Test
        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);
        }
コード例 #26
0
ファイル: tstGame.cs プロジェクト: Owen2533667/Skeleton
        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);
        }
コード例 #27
0
        public void ValidMethodOK()
        {
            clsGame aGame = new clsGame();
            string  Error;

            Error = aGame.Valid(GameTitle, Price, Discount, DatePublished);
            Assert.AreEqual(Error, "");
        }
コード例 #28
0
        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, "");
        }
コード例 #29
0
        public void GameTitleMinPlusOne()
        {
            clsGame aGame     = new clsGame();
            string  TestTitle = "12";
            string  Error     = aGame.Valid(TestTitle, Price, Discount, DatePublished);

            Assert.AreEqual(Error, "");
        }
コード例 #30
0
        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, "");
        }
コード例 #31
0
 public void SetDetails(clsGame prGame)
 {
     _Game = prGame;
     updateForm();
     ShowDialog();
 }