public void AddMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStock           TestItem = new clsStock();
            Int32 PrimaryKey            = 0;

            TestItem.Availability     = true;
            TestItem.StockNo          = 1;
            TestItem.OrderNo          = 1;
            TestItem.DatePurchased    = DateTime.Now.Date;
            TestItem.StockDescription = "Small";
            TestItem.Quantity         = 1;
            AllStock.ThisStock        = TestItem;
            PrimaryKey       = AllStock.Add();
            TestItem.StockNo = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Exemple #2
0
        public void AddMethodOK()
        {
            clsStockCollection AllStocks = new clsStockCollection();
            clsStock           TestItem  = new clsStock();
            Int32 PrimaryKey             = 0;

            TestItem.ClothesColour      = "red";
            TestItem.ClothesDescription = "LargeShirt";
            TestItem.DateAdded          = DateTime.Now.Date;
            TestItem.Price      = 1;
            TestItem.Available  = true;
            TestItem.ClothesNo  = 1;
            AllStocks.ThisStock = TestItem;
            PrimaryKey          = AllStocks.Add();
            TestItem.ClothesNo  = PrimaryKey;
            AllStocks.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(AllStocks.ThisStock, TestItem);
        }
Exemple #3
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsStock stock = new clsStock();

        string Description  = txtDescription.Text;
        string Price        = txtPrice.Text;
        string Next_Intake  = txtNext_Intake.Text;
        string Pristine     = txtPristine.Text;
        string Non_Pristine = txtNon_Pristine.Text;

        string Error = "";

        Error = stock.Valid(Description, Price, Pristine, Non_Pristine, Next_Intake);

        if (Error == "")
        {
            stock.Product_Code = Product_Code;
            stock.Description  = Description;
            stock.Price        = Convert.ToDouble(Price);
            stock.Next_Intake  = Convert.ToDateTime(Next_Intake);
            stock.Pristine     = Convert.ToInt32(Pristine);
            stock.Non_Pristine = Convert.ToInt32(Non_Pristine);
            stock.Clearence    = checkClearence.Checked;

            clsStockCollection StockList = new clsStockCollection();

            if (Product_Code == -1)
            {
                StockList.ThisStock = stock;
                StockList.Add();
            }
            else
            {
                StockList.ThisStock.Find(Product_Code);
                StockList.ThisStock = stock;
                StockList.Update();
            }
            Response.Redirect("StockList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Exemple #4
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create new instance of clsStock
        clsStock AStock = new clsStock();
        //capture the BookID
        string BookID = txtBookID.Text;
        //capture the BookName
        string BookName = txtBookName.Text;
        //capture the number available
        string NumberAvailable = txtNumberAvailable.Text;
        //capture the release date
        string ReleaseDate = txtReleaseDate.Text;

        //variable to store error messages
        string Error = "";

        //validate the data
        Error = AStock.Valid(BookName, NumberAvailable, ReleaseDate);
        if (Error == "")
        {
            //capture the BookID
            AStock.BookID = long.Parse(txtBookID.Text);
            //capture the BookName
            AStock.BookName = txtBookName.Text;
            //capture the number available
            AStock.NumberAvailable = int.Parse(txtNumberAvailable.Text);
            //capture the release date
            AStock.ReleaseDate = Convert.ToDateTime(txtReleaseDate.Text);
            //create a new instance of the stock collection
            clsStockCollection StockList = new clsStockCollection();
            //set the ThisStock property
            StockList.ThisStock = AStock;
            //add the new record
            StockList.Add();
            //redirect back to the listpage
            Response.Redirect("StockList.aspx");
        }
        else
        {
            //display the error message
            lblError.Text = Error;
        }
    }
Exemple #5
0
        public void AddMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStaff           TestItem = new clsStaff();
            Int32 PrimaryKey            = 0;

            TestItem.StaffId            = 1;
            TestItem.ProductName        = "jeans";
            TestItem.StockVariants      = 278;
            TestItem.Price              = 17;
            TestItem.StaffFirstName     = 75;
            TestItem.LastRestockDate    = DateTime.Now.Date;
            TestItem.ProductDescription = "tapered jeans";
            AllStock.ThisStock          = TestItem;
            PrimaryKey       = AllStock.Add();
            TestItem.StaffId = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Exemple #6
0
        public void AddMethodOK()
        {
            clsStockCollection AllProducts = new clsStockCollection();
            clsStock           TestItem    = new clsStock();

            TestItem.ProductName     = "Nike";
            TestItem.ProductNo       = 1;
            TestItem.QuantityOrdered = 1;
            TestItem.QuantityInStock = 1;
            TestItem.Price           = 1;
            TestItem.Date            = DateTime.Now.Date;
            Int32 PrimaryKey = 1;

            AllProducts.ThisProduct = TestItem;
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductNo = PrimaryKey;
            AllProducts.ThisProduct.Find(PrimaryKey);
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
        public void AddMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStock           TestItem = new clsStock();
            Int32 PrimaryKey            = 0;

            TestItem.PCName         = "true";
            TestItem.RAM            = 1;
            TestItem.CPU            = "1";
            TestItem.GPU            = "1";
            TestItem.Builddate      = DateTime.Now.Date;
            TestItem.StockAvaliable = 1;
            TestItem.StorageType    = 2;
            AllStock.ThisStock      = TestItem;
            PrimaryKey      = AllStock.Add();
            TestItem.PCIDNo = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
        public void AddMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();

            clsStock TestItem   = new clsStock();
            Int32    PrimaryKey = 0;

            TestItem.Available       = true;
            TestItem.PartNo          = 1;
            TestItem.DateAdded       = DateTime.Now.Date;
            TestItem.Price           = 1;
            TestItem.Quantity        = 1;
            TestItem.PartDescription = "";

            AllStock.ThisStock = TestItem;
            PrimaryKey         = AllStock.Add();
            AllStock.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Exemple #9
0
    void Add()
    {
        clsStockCollection StockBook = new clsStockCollection();
        Boolean            OK        = StockBook.ThisStock.ValidExists(TextBoxName.Text, TextBoxDesc.Text, TextBoxLevel.Text, TextBoxPrice.Text);

        if (OK == true)
        {
            StockBook.ThisStock.ItemName         = TextBoxName.Text;
            StockBook.ThisStock.StockDescription = TextBoxDesc.Text;
            StockBook.ThisStock.StockLevel       = Convert.ToInt32(TextBoxLevel.Text);
            StockBook.ThisStock.StockPrice       = Convert.ToDecimal(TextBoxPrice.Text);

            StockBook.Add();
        }

        else
        {
            lblError.Text = "There were problems with the data entered";
        }
    }
Exemple #10
0
        public void DeleteMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStock           TestItem = new clsStock();
            Int32 PrimaryKey            = 0;

            TestItem.BookID          = 9780545010221;
            TestItem.BookName        = "Harry Potter and the Deathly Hallows";
            TestItem.NumberAvailable = 59;
            TestItem.ReleaseDate     = new DateTime(2007, 7, 21);
            TestItem.InStock         = true;
            AllStock.ThisStock       = TestItem;
            PrimaryKey      = AllStock.Add();
            TestItem.BookID = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            AllStock.Delete();
            Boolean Found = AllStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
        public void AddMethodOK()
        {
            clsStockCollection AllProducts = new clsStockCollection();
            clsStock           TestProduct = new clsStock();
            int PrimaryKey = 0;

            TestProduct.ProductId          = 1;
            TestProduct.ProductName        = "game 2";
            TestProduct.ReleaseDate        = DateTime.Now.Date;
            TestProduct.Price              = Convert.ToDecimal(4.20);
            TestProduct.InStock            = false;
            TestProduct.ProductDescription = "yet another game";

            AllProducts.ThisProduct = TestProduct;
            PrimaryKey            = AllProducts.Add();
            TestProduct.ProductId = PrimaryKey;

            AllProducts.ThisProduct.Find(PrimaryKey);
            Assert.AreEqual(AllProducts.ThisProduct, TestProduct);
        }
        public void DeleteMethodOK()
        {
            clsStockCollection allStock  = new clsStockCollection();
            clsStock           TestStock = new clsStock();
            Int32 PrimaryKey             = 0;

            TestStock.PartDescription = "Monitor";
            TestStock.Quantity        = 2;
            TestStock.Price           = 2;
            TestStock.DateAdded       = DateTime.Now.Date;
            TestStock.Available       = true;
            allStock.ThisStock        = TestStock;
            PrimaryKey       = allStock.Add();
            TestStock.PartNo = PrimaryKey;
            allStock.ThisStock.Find(PrimaryKey);
            allStock.Delete();
            Boolean Found = allStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #13
0
    protected void btnOK_Click1(object sender, EventArgs e)
    {
        //create an instance of the stock class
        clsStock AnStock = new clsStock();
        //capture the clothes colour
        string ClothesColour = txtClothesColour.Text;
        //capture the ClothesDescription
        string ClothesDescription = txtClothesDescription.Text;
        //capture the price
        string Price = txtPrice.Text;
        //capture the date added
        string DateAdded = txtDateAdded.Text;
        string Error     = "";

        //validate the error
        Error = AnStock.Valid(ClothesDescription, ClothesColour, DateAdded, Price);


        if (Error == "")
        {
            //capture clothes Description
            AnStock.ClothesDescription = ClothesDescription;
            //capture clothes colour
            AnStock.ClothesColour = ClothesColour;

            //capture dateadded
            AnStock.DateAdded = Convert.ToDateTime(DateAdded);
            AnStock.Available = chkAvailable.Checked;
            clsStockCollection StockList = new clsStockCollection();
            StockList.ThisStock = AnStock;
            StockList.Add();

            //redirect to viewer page
            Response.Redirect("StockViewer.aspx");
        }
        else
        {
            //display the error message
            iblError.Text = Error;
        }
    }
Exemple #14
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //create a new instance of clsStock
        clsStock ABook             = new clsStock();
        string   BookDescription   = txtBookDescription.Text;
        string   Price             = txtPrice.Text;
        string   QuantityAvailable = txtQuantity.Text;
        string   DateAdded         = txtDateAdded.Text;
        string   Error             = "";

        Error = ABook.Valid(BookDescription, Price, QuantityAvailable, DateAdded);
        if (Error == "")
        {
            ABook.BookId      = Convert.ToInt32(BookId);
            ABook.Description = BookDescription;
            ABook.Price       = Convert.ToDouble(Price);
            ABook.Quantity    = Convert.ToInt32(QuantityAvailable);
            ABook.DateAdded   = Convert.ToDateTime(DateAdded);
            ABook.Available   = chkAvailable.Checked;
            clsStockCollection StockList = new clsStockCollection();

            if (BookId == -1)
            {
                //set the ThisStock property
                StockList.ThisStock = ABook;
                //add the new record
                StockList.Add();
            }
            else
            {
                StockList.ThisStock.Find(BookId);
                StockList.ThisStock = ABook;
                StockList.Update();
            }
            Response.Redirect("StockList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Exemple #15
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        clsStock AProduct          = new clsStock();
        string   ProductID         = txtProductId.Text;
        string   StyleName         = txtStyleName.Text;
        string   BackInStockDate   = txtBackInStockDate.Text;
        string   Price             = txtPrice.Text;
        string   QuantityAvailable = txtQuantityAvailable.Text;


        string Error = "";

        Error = AProduct.Valid(StyleName, BackInStockDate, Price, QuantityAvailable);
        if (Error == "")
        {
            AProduct.ProductId         = Convert.ToInt32(ProductID);
            AProduct.StyleName         = StyleName;
            AProduct.Price             = Convert.ToDouble(Price);
            AProduct.QuantityAvailable = Convert.ToInt32(QuantityAvailable);
            AProduct.BackInStockDate   = Convert.ToDateTime(BackInStockDate);
            AProduct.LimitedEdition    = chkLimitedEdition.Checked;
            clsStockCollection ProductList = new clsStockCollection();
            if (Convert.ToInt32(ProductID) == -1)
            {
                ProductList.ThisProduct = AProduct;
                ProductList.Add();
            }
            else
            {
                ProductList.ThisProduct.Find(ProductId);
                ProductList.ThisProduct = AProduct;
                ProductList.Update();
            }

            Response.Redirect("ProductList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
        public void DeleteMethodOk()
        {
            clsStockCollection AllStocks = new clsStockCollection();
            clsStock           TestItem  = new clsStock();
            Int32 PrimaryKey             = 0;

            TestItem.Name       = "Mercurial Dream Superfly 8";
            TestItem.DateAdded  = DateTime.Now.Date;
            TestItem.Category   = "Football Boots";
            TestItem.Brand      = "Nike";
            TestItem.Size       = "UK 6 (EU 39)";
            TestItem.Active     = true;
            AllStocks.ThisStock = TestItem;
            PrimaryKey          = AllStocks.Add();
            TestItem.ItemNo     = PrimaryKey;
            AllStocks.ThisStock.Find(PrimaryKey);
            AllStocks.Delete();
            Boolean Found = AllStocks.ThisStock.Find(PrimaryKey);

            Assert.IsTrue(Found);
        }
        public void DeleteMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStock           TestItem = new clsStock();
            Int32 PrimaryKey            = 0;

            TestItem.Availability     = true;
            TestItem.StockNo          = 1;
            TestItem.OrderNo          = 1;
            TestItem.DatePurchased    = DateTime.Now.Date;
            TestItem.StockDescription = "large";
            TestItem.Quantity         = 1;
            AllStock.ThisStock        = TestItem;
            PrimaryKey       = AllStock.Add();
            TestItem.StockNo = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            AllStock.Delete();
            Boolean Found = AllStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #18
0
        public void DeleteMethodOK()
        {
            clsStockCollection AllProducts = new clsStockCollection();
            clsStock           TestItem    = new clsStock();
            Int32 PrimaryKey = 0;

            TestItem.ProductId         = 1;
            TestItem.LimitedEdition    = true;
            TestItem.StyleName         = "Test Style Name";
            TestItem.Price             = 49.99;
            TestItem.QuantityAvailable = 10;
            TestItem.BackInStockDate   = DateTime.Now.Date;
            AllProducts.ThisProduct    = TestItem;
            PrimaryKey         = AllProducts.Add();
            TestItem.ProductId = PrimaryKey;
            AllProducts.ThisProduct.Find(PrimaryKey);
            AllProducts.Delete();
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #19
0
        public void DeleteMethodOk()
        {
            clsStockCollection AllStocks = new clsStockCollection();
            clsStock           TestItem  = new clsStock();
            Int32 PrimaryKey             = 0;

            TestItem.ClothesColour      = "red";
            TestItem.ClothesDescription = "LargeShirt";
            TestItem.DateAdded          = DateTime.Now.Date;
            TestItem.Price      = 1;
            TestItem.Available  = true;
            TestItem.ClothesNo  = 1;
            AllStocks.ThisStock = TestItem;
            PrimaryKey          = AllStocks.Add();
            TestItem.StockNo    = PrimaryKey;
            AllStocks.ThisStock.Find(PrimaryKey);
            AllStocks.Delete();
            Boolean Found = AllStocks.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #20
0
        public void AddMethodOK()
        {
            //create an instance fof the class we want to create
            clsStockCollection AllStocks = new clsStockCollection();
            //create some test data to assign to the property
            clsStock TestItem   = new clsStock();
            Int32    Primarykey = 0;

            TestItem.Available   = true;
            TestItem.ProductID   = 1;
            TestItem.BookName    = "Unfinished";
            TestItem.AuthorName  = "Priyanka Chopra";
            TestItem.Price       = 11;
            TestItem.PublishDate = Convert.ToDateTime("09/02/2021");

            AllStocks.ThisStock = TestItem;
            Primarykey          = AllStocks.Add();
            TestItem.ProductID  = Primarykey;
            AllStocks.ThisStock.Find(Primarykey);
            Assert.AreEqual(AllStocks.ThisStock, TestItem);
        }
Exemple #21
0
        public void DeleteMethodOK()
        {
            clsStockCollection AllStocks = new clsStockCollection();
            clsStock           TestItem  = new clsStock();
            Int32 PrimaryKey             = 0;

            TestItem.Available   = true;
            TestItem.ProductID   = 1;
            TestItem.BookName    = "Unfinished";
            TestItem.AuthorName  = "Priyanka Chopra";
            TestItem.Price       = 11;
            TestItem.PublishDate = Convert.ToDateTime("09/02/2021");
            AllStocks.ThisStock  = TestItem;
            PrimaryKey           = AllStocks.Add();
            TestItem.ProductID   = PrimaryKey;
            AllStocks.ThisStock.Find(PrimaryKey);
            AllStocks.Delete();
            Boolean Found = AllStocks.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #22
0
        public void DeleteMethodOK()
        {
            clsStockCollection AllProducts = new clsStockCollection();
            clsStock           TestItem    = new clsStock();
            Int32 PrimaryKey = 1;

            TestItem.ProductNo       = 1;
            TestItem.ProductName     = "Nike";
            TestItem.QuantityOrdered = 1;
            TestItem.QuantityInStock = 1;
            TestItem.Price           = 1;
            TestItem.Date            = DateTime.Now.Date;
            AllProducts.ThisProduct  = TestItem;
            PrimaryKey              = AllProducts.Add();
            TestItem.ProductNo      = PrimaryKey;
            AllProducts.ThisProduct = TestItem;
            AllProducts.Delete();
            Boolean Found = AllProducts.ThisProduct.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #23
0
        public void UpdateMethodOK()
        {
            //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.Available        = true;
            TestItem.StockID          = 1;
            TestItem.StockDescription = "Converse";
            TestItem.StockColour      = "Red";
            TestItem.StockAmount      = 300;
            TestItem.StockPrice       = 20.00M;
            TestItem.DateOrdered      = DateTime.Now.Date;
            //set this stock to the test data
            AllStock.ThisStock = TestItem;
            //add the record
            PrimaryKey = AllStock.Add();
            //set the primary key of the test data
            TestItem.StockID = PrimaryKey;
            //modify the test data
            TestItem.Available        = false;
            TestItem.StockID          = 3;
            TestItem.StockDescription = "AirMax";
            TestItem.StockColour      = "Yellow";
            TestItem.StockAmount      = 15;
            TestItem.StockPrice       = 40.00M;
            TestItem.DateOrdered      = DateTime.Now.Date;
            //set the record based on the new test data
            AllStock.ThisStock = TestItem;
            //update the record
            AllStock.Update();
            //find the record
            AllStock.ThisStock.Find(PrimaryKey);
            //test to see thisAddress matches testdata
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Exemple #24
0
        public void deleteMethodOk()
        {
            clsStockCollection allStock = new clsStockCollection();

            clsStock testStock = new clsStock();

            string primaryKey = "";

            var chars       = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            var stringChars = new char[8];
            var random      = new Random();

            for (int i = 0; i < stringChars.Length; i++)
            {
                stringChars[i] = chars[random.Next(chars.Length)];
            }

            var finalString = new String(stringChars);

            testStock.numberPlate    = finalString;
            testStock.productionDate = DateTime.Now.Date;
            testStock.mileage        = 20000;
            testStock.price          = 5000;
            testStock.sold           = false;
            testStock.modelName      = "model";

            allStock.thisStock = testStock;

            primaryKey = allStock.Add().ToString();

            testStock.numberPlate = primaryKey;

            allStock.thisStock.Find(primaryKey);

            allStock.Delete();

            Boolean Found = allStock.thisStock.Find(primaryKey);

            Assert.IsFalse(Found);
        }
        public void UpdateMethodOK()
        {
            //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 Doulbe or int32 ----------
            Int32 PrimaryKey = 0;

            //set its properties
            TestItem.Active      = true;
            TestItem.Gender      = "Male";
            TestItem.Size        = "Medium";
            TestItem.Description = "Nice shoes";
            TestItem.Price       = 120.99;
            TestItem.InStock     = true;
            TestItem.DateArrived = 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.Price = PrimaryKey;
            //modify the test data
            TestItem.Active      = true;
            TestItem.Gender      = "Female";
            TestItem.Size        = "Small";
            TestItem.Description = "Nice coat";
            TestItem.Price       = 25.99;
            TestItem.InStock     = true;
            TestItem.DateArrived = DateTime.Now.Date;
            //set the record based on the new test data
            AllStock.ThisStock = TestItem;
            //update the record
            AllStock.Update();
            //find the record
            AllStock.ThisStock.Find(PrimaryKey);
            //test to see ThisStock matches the test data
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Exemple #26
0
        public void UpdateMethodOK()
        {
            // instantiate collection class
            clsStockCollection AllStock = new clsStockCollection(); //instantiate class
            // instantiate stock item
            clsStock AnItem = new clsStock();
            // int for primary key
            Int32 pk = 0;

            // test data
            AnItem.productName  = "ASUS Netbook";
            AnItem.productPrice = 49.99;
            AnItem.modelNo      = "EEE PC 1015BX";
            AnItem.netWeight    = 1.50;
            AnItem.grossWeight  = 1.80;
            AnItem.releaseDate  = DateTime.Now.Date;
            AnItem.visible      = true;
            // set collection ThisItem to test data
            AllStock.ThisItem = AnItem;
            // add record
            pk = AllStock.Add();
            // set primary key of test data
            AnItem.productId = pk;
            // modify test data
            AnItem.productName  = "ASUS Desktop PC";
            AnItem.productPrice = 159.99;
            AnItem.modelNo      = "x350";
            AnItem.netWeight    = 2.50;
            AnItem.grossWeight  = 2.80;
            AnItem.releaseDate  = DateTime.Now.Date;
            AnItem.visible      = false;
            // set record based on new test data
            AllStock.ThisItem = AnItem;
            // update record
            AllStock.Update();
            // find record
            AllStock.ThisItem.Find(pk);
            // test to see ThisItem matches test data
            Assert.AreEqual(AllStock.ThisItem, AnItem);
        }
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsStockCollection AllStocks = new clsStockCollection();
            clsStock           TestItem  = new clsStock();
            Int32 PrimaryKey             = 0;

            //Creating test data for each attribute
            TestItem.Availability = true;
            TestItem.gameID       = 1;
            TestItem.gameName     = "Some Game";
            TestItem.Price        = 10;
            TestItem.ReleaseDate  = DateTime.Now.Date;
            TestItem.AgeRating    = 3;
            AllStocks.ThisStock   = TestItem;
            PrimaryKey            = AllStocks.Add();
            TestItem.gameID       = PrimaryKey;
            AllStocks.ThisStock.Find(PrimaryKey);

            //test to see if it passes
            Assert.AreEqual(AllStocks.ThisStock, TestItem);
        }
        public void AddMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            Int32    PrimaryKey         = 0;
            clsStock TestItem           = new clsStock();

            TestItem.StockID          = 4;
            TestItem.ItemName         = "GTX 780";
            TestItem.StockDescription = "NVIDIA GPU";
            TestItem.StockLevel       = 1;
            TestItem.StockPrice       = 150;

            AllStock.ThisStock = TestItem;

            PrimaryKey = AllStock.Add();

            TestItem.StockID = PrimaryKey;

            AllStock.ThisStock.Find(PrimaryKey);

            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
        public void DeleteMethodOk()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStock           TestItem = new clsStock();
            Int32 PrimaryKey            = 0;

            TestItem.PCName         = "true";
            TestItem.RAM            = 1;
            TestItem.CPU            = "1";
            TestItem.GPU            = "1";
            TestItem.Builddate      = DateTime.Now.Date;
            TestItem.StockAvaliable = 1;
            TestItem.StorageType    = 2;
            AllStock.ThisStock      = TestItem;
            PrimaryKey      = AllStock.Add();
            TestItem.PCIDNo = PrimaryKey;
            AllStock.ThisStock.Find(PrimaryKey);
            AllStock.Delete();
            Boolean Found = AllStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Exemple #30
0
        public void UpdateMethodOK()
        {
            //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;
            //modify the test data
            TestItem.InStck          = false;
            TestItem.ProductNo       = 3;
            TestItem.ProductDescript = "Chelsea Shirt";
            TestItem.Cost            = 59;
            TestItem.StockNo         = 49;
            TestItem.DateAdded       = DateTime.Now.Date;
            //set the record based on the new test data
            //update the record
            AllStock.ThisStock = TestItem;
            //update the record
            AllStock.Update();
            //find the record
            AllStock.ThisStock.Find(PrimaryKey);
            //test to see ThisStock matches the test data
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }