Example #1
0
        public void ReportByGameTitleNoneFound()
        {
            clsGamesCollection FilteredGames = new clsGamesCollection();

            FilteredGames.ReportByGameTitle("some game that doesn't exist");
            Assert.AreEqual(0, FilteredGames.Count);
        }
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        String  StrDatePublished = calDatePublished.SelectedDate.ToLongDateString();
        clsGame aGame            = new clsGame();
        String  Error            = aGame.Valid(txtGameTitle.Text, txtPrice.Text, txtDiscount.Text, StrDatePublished);

        if (Error == "")
        {
            aGame.GameId        = GameId;
            aGame.GameTitle     = txtGameTitle.Text;
            aGame.Price         = Convert.ToDouble(txtPrice.Text);
            aGame.Discount      = Convert.ToInt32(txtDiscount.Text);
            aGame.DatePublished = calDatePublished.SelectedDate;
            aGame.Active        = chkActive.Checked;
            clsGamesCollection GamesList = new clsGamesCollection();
            if (GameId == -1)
            {
                GamesList.ThisGame = aGame;
                GamesList.Add();
            }
            else
            {
                GamesList.ThisGame.Find(GameId);
                GamesList.ThisGame = aGame;
                GamesList.Update();
            }
            Response.Redirect("GamesList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();
            //create th eitme of test data
            clsGames TestItem = new clsGames();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Game_ID          = 1;
            TestItem.Game_Name        = "Areeb";
            TestItem.Game_Description = "This is my test data";
            TestItem.Game_Quantity    = 31;
            TestItem.Platform         = "Nintendo switch";
            TestItem.Supplier_ID      = 11;
            //set this game to the test data
            AllGames.ThisGame = TestItem;
            //add the record
            PrimaryKey = AllGames.Add();
            //set the primary key of the tst data
            TestItem.Game_ID = PrimaryKey;
            //find the rocrd
            AllGames.ThisGame.Find(PrimaryKey);
            //test to see that the 2 values are the same
            Assert.AreEqual(AllGames.ThisGame, TestItem);
        }
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();
            //create some test data to assign to the property
            //in this case the data needs to be list of objects.
            List <clsGames> TestList = new List <clsGames>();
            //add an item to the list
            //create the item of test data
            clsGames TestItem = new clsGames();

            //set its properties
            TestItem.Game_ID          = 1;
            TestItem.Game_Name        = "Areeb";
            TestItem.Game_Description = "This is my test description";
            TestItem.Game_Quantity    = 25;
            TestItem.Platform         = "Xbox";
            TestItem.Supplier_ID      = 21;
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllGames.Gameslist = TestList;
            //test to see that the 2 values are the same
            Assert.AreEqual(AllGames.Count, TestList.Count);
        }
        public void DeleteMethodOK()
        {
            //crate an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();
            //crate the item of test data
            clsGames TestItem = new clsGames();

            //var to store the primry key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.Game_ID          = 1;
            TestItem.Game_Name        = "Areeb";
            TestItem.Game_Description = "This is my tes data";
            TestItem.Game_Quantity    = 25;
            TestItem.Platform         = "PlayStation";
            TestItem.Supplier_ID      = 21;
            //set this game to the test data
            AllGames.ThisGame = TestItem;
            //add the record
            Primarykey = AllGames.Add();
            // set the primary key of the test data
            TestItem.Game_ID = Primarykey;
            //find the record
            AllGames.ThisGame.Find(Primarykey);
            //delete the record
            AllGames.Delete();
            //now find the record
            Boolean Found = AllGames.ThisGame.Find(Primarykey);

            //test to see that the record was not found
            Assert.IsFalse(Found);
        }
Example #6
0
    void Update()
    {
        //create an instance of the gamesstore
        clsGamesCollection GamesStore = new clsGamesCollection();
        //validate the data on the web form
        String Error = GamesStore.ThisGame.Valid(txtGame_Name.Text, txtGame_Description.Text, txtGame_Quantity.Text, txtPlatform.Text, txtSupplier_ID.Text);

        //if the ata is ok then add it to the object
        if (Error == "")
        {
            GamesStore.ThisGame.Find(Game_ID);
            //get the data entered by the user
            GamesStore.ThisGame.Game_Name        = txtGame_Name.Text;
            GamesStore.ThisGame.Game_Description = txtGame_Description.Text;
            GamesStore.ThisGame.Game_Quantity    = Convert.ToInt32(txtGame_Quantity.Text);
            GamesStore.ThisGame.Platform         = txtPlatform.Text;
            GamesStore.ThisGame.Supplier_ID      = Convert.ToInt32(txtSupplier_ID.Text);
            //update the record
            GamesStore.Update();
            Response.Redirect("Default.aspx");
        }

        else
        {
            //report an error
            lblError.Text = "There was a problem" + Error;
        }
    }
    protected void btnYes_Click(object sender, EventArgs e)
    {
        clsGamesCollection GamesList = new clsGamesCollection();

        GamesList.ThisGame.Find(GameId);
        GamesList.Delete();
        Response.Redirect("GamesList.aspx");
    }
Example #8
0
        public void ReportByGameTitle()
        {
            clsGamesCollection AllGames      = new clsGamesCollection();
            clsGamesCollection FilteredGames = new clsGamesCollection();

            FilteredGames.ReportByGameTitle("");
            Assert.AreEqual(AllGames.Count, FilteredGames.Count);
        }
        public void InstanceOK()

        {
            //create an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();

            //test to see that it exists
            Assert.IsNotNull(AllGames);
        }
Example #10
0
    void DisplayGames()
    {
        clsGamesCollection Games = new clsGamesCollection();

        lstGamesList.DataSource     = Games.GamesList;
        lstGamesList.DataValueField = "GameId";
        lstGamesList.DataTextField  = "GameTitle";
        lstGamesList.DataBind();
    }
Example #11
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsGamesCollection Games = new clsGamesCollection();

        Games.ReportByGameTitle(txtTitleQuery.Text);
        lstGamesList.DataSource     = Games.GamesList;
        lstGamesList.DataValueField = "GameId";
        lstGamesList.DataTextField  = "GameTitle";
        lstGamesList.DataBind();
    }
Example #12
0
    void Delete()
    {
        //function to delete selected record
        //create a new instance of the address book
        clsGamesCollection GamesStore = new clsGamesCollection();

        //find the record to delete
        GamesStore.ThisGame.Find(Game_ID);
        //delete the record
        GamesStore.Delete();
    }
Example #13
0
        public void ThisGamePropertyOK()
        {
            clsGamesCollection AllGames = new clsGamesCollection();
            clsGame            TestGame = new clsGame();

            TestGame.GameId        = 7;
            TestGame.GameTitle     = "Some Game";
            TestGame.Price         = 11.99;
            TestGame.Discount      = 20;
            TestGame.DatePublished = DateTime.Now.Date;
            TestGame.Active        = true;
            AllGames.ThisGame      = TestGame;
            Assert.AreEqual(AllGames.ThisGame, TestGame);
        }
Example #14
0
    void DisplayGames()
    {
        //crete an instanc eof the games store
        clsGamesCollection GamesStore = new clsGamesCollection();

        //find the record to update
        GamesStore.ThisGame.Find(Game_ID);
        //display the data for this record
        txtGame_Name.Text        = GamesStore.ThisGame.Game_Name;
        txtGame_Description.Text = GamesStore.ThisGame.Game_Description;
        txtGame_Quantity.Text    = GamesStore.ThisGame.Game_Quantity.ToString();
        txtPlatform.Text         = GamesStore.ThisGame.Platform;
        txtSupplier_ID.Text      = GamesStore.ThisGame.Supplier_ID.ToString();
    }
    private void DisplayGame()
    {
        clsGamesCollection GamesList = new clsGamesCollection();

        GamesList.ThisGame.Find(GameId);
        clsGame aGame = GamesList.ThisGame;

        txtGameId.Text                = aGame.GameId.ToString();
        txtGameTitle.Text             = aGame.GameTitle;
        txtPrice.Text                 = aGame.Price.ToString();
        txtDiscount.Text              = aGame.Discount.ToString();
        calDatePublished.SelectedDate = aGame.DatePublished;
        calDatePublished.VisibleDate  = aGame.DatePublished;
        chkActive.Checked             = aGame.Active;
    }
Example #16
0
        public void ListAndCountOK()
        {
            clsGamesCollection AllGames = new clsGamesCollection();
            List <clsGame>     TestList = new List <clsGame>();
            clsGame            TestGame = new clsGame();

            TestGame.GameId        = 7;
            TestGame.GameTitle     = "Some Game";
            TestGame.Price         = 11.99;
            TestGame.Discount      = 20;
            TestGame.DatePublished = DateTime.Now.Date;
            TestGame.Active        = true;
            TestList.Add(TestGame);
            AllGames.GamesList = TestList;
            Assert.AreEqual(AllGames.Count, TestList.Count);
        }
Example #17
0
        public void AddMethodOK()
        {
            clsGamesCollection AllGames = new clsGamesCollection();
            clsGame            TestGame = new clsGame();
            int PrimaryKey = 0;

            TestGame.GameTitle     = "Some Game";
            TestGame.Price         = 11.99;
            TestGame.Discount      = 20;
            TestGame.DatePublished = DateTime.Now.Date;
            TestGame.Active        = true;
            AllGames.ThisGame      = TestGame;
            PrimaryKey             = AllGames.Add();
            TestGame.GameId        = PrimaryKey;
            AllGames.ThisGame.Find(PrimaryKey);
            Assert.AreEqual(AllGames.ThisGame, TestGame);
        }
        public void ThisGamePropertyOK()
        {
            //create an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();
            //create some test data to assign to the property
            clsGames TestGame = new clsGames();

            //set the properties of the test object
            TestGame.Game_ID          = 1;
            TestGame.Game_Name        = "Areeb";
            TestGame.Game_Description = "This is my test data";
            TestGame.Game_Quantity    = 25;
            TestGame.Platform         = "Xbox";
            TestGame.Supplier_ID      = 21;
            //assign the data to the property
            AllGames.ThisGame = TestGame;
            //test to see that the values are equal
            Assert.AreEqual(AllGames.ThisGame, TestGame);
        }
Example #19
0
        public void DeleteMethodOK()
        {
            clsGamesCollection AllGames = new clsGamesCollection();
            clsGame            TestGame = new clsGame();
            int PrimaryKey = 0;

            TestGame.GameTitle     = "Some Game";
            TestGame.Price         = 11.99;
            TestGame.Discount      = 20;
            TestGame.DatePublished = DateTime.Now.Date;
            TestGame.Active        = true;
            AllGames.ThisGame      = TestGame;
            PrimaryKey             = AllGames.Add();
            TestGame.GameId        = PrimaryKey;
            AllGames.ThisGame.Find(PrimaryKey);
            AllGames.Delete();
            bool Found = AllGames.ThisGame.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsGamesCollection AllGames = new clsGamesCollection();
            //create the item of test data
            clsGames TestItem = new clsGames();
            //var to store the primry key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.Game_ID          = 1;
            TestItem.Game_Name        = "Areeb";
            TestItem.Game_Description = "This is my tes data";
            TestItem.Game_Quantity    = 25;
            TestItem.Platform         = "PlayStation";
            TestItem.Supplier_ID      = 21;
            //set this game to the test data
            AllGames.ThisGame = TestItem;
            //add the record
            Primarykey = AllGames.Add();
            // set the primary key of the test data
            TestItem.Game_ID = Primarykey;
            //modify the test data
            TestItem.Game_ID          = 2;
            TestItem.Game_Name        = "Beera";
            TestItem.Game_Description = "This is'nt my test data";
            TestItem.Game_Quantity    = 26;
            TestItem.Platform         = "PlayStation4";
            TestItem.Supplier_ID      = 22;
            //set the record based on the neew test data
            AllGames.ThisGame = TestItem;
            //update the record
            AllGames.Update();
            //find the record
            AllGames.ThisGame.Find(Primarykey);
            // test to see this game matches the test data
            Assert.AreEqual(AllGames.ThisGame, TestItem);
        }
Example #21
0
        public void InstanceOK()
        {
            clsGamesCollection AllGames = new clsGamesCollection();

            Assert.IsNotNull(AllGames);
        }