Esempio n. 1
0
        public void DeleteMethodOkay()
        {
            clsStockCollection allStock = new clsStockCollection();
            clsStock           aBook    = new clsStock();
            int PrimaryKey = 0;

            aBook.ISBN         = "3333333333333";
            aBook.BookName     = "testbook";
            aBook.Author       = "Terry Pratchett";
            aBook.OnOrder      = false;
            aBook.StockLevel   = 100;
            aBook.Price        = 9.99;
            aBook.SupplierID   = 1;
            aBook.ReleaseDate  = Convert.ToDateTime("25/9/2004");
            allStock.ThisStock = aBook;
            PrimaryKey         = allStock.Add();
            allStock.ThisStock.Find(PrimaryKey);
            allStock.Delete();
            Boolean Found = allStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Esempio n. 2
0
        public void DeleteMethodOK()
        {
            clsStockCollection AllStock = new clsStockCollection();
            clsStaff           TestItem = new clsStaff();
            Int32 PrimaryKey            = 0;

            //data to delete
            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);
            AllStock.Delete();
            Boolean Found = AllStock.ThisStock.Find(PrimaryKey);

            Assert.IsFalse(Found);
        }
Esempio n. 3
0
        public void ListAndCountOK()
        {
            clsStockCollection AllStock = new clsStockCollection(); //instantiate class

            List <clsStock> TestList = new List <clsStock>();       // create empty list

            clsStock AnItem = new clsStock();

            AnItem.productName  = "ASUS Laptop";
            AnItem.productPrice = 199.99;
            AnItem.modelNo      = "x200";
            AnItem.netWeight    = 1.50;
            AnItem.grossWeight  = 1.80;
            AnItem.releaseDate  = DateTime.Now.Date;
            AnItem.visible      = true;

            TestList.Add(AnItem);

            AllStock.StockList = TestList;

            Assert.AreEqual(AllStock.Count, TestList.Count);
        }
Esempio n. 4
0
        public void UpdateMethodOK()
        {
            //create an instance of the class
            clsStockCollection AllStock = new clsStockCollection();
            //create the item of test data
            clsStock TestItem = new clsStock();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set the properties
            TestItem.Available   = true;
            TestItem.BookId      = 1;
            TestItem.DateAdded   = DateTime.Now.Date;
            TestItem.Description = "Mr and Mrs Twit, Roald Dahl";
            TestItem.Price       = 8.99;
            TestItem.Quantity    = 30;
            //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.BookId = PrimaryKey;
            //modify the test data
            TestItem.Available   = false;
            TestItem.BookId      = 3;
            TestItem.DateAdded   = DateTime.Now.Date;
            TestItem.Description = "Mr and Mrs Twit, Roald Dahl";
            TestItem.Price       = 8.00;
            TestItem.Quantity    = 10;
            //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 that the two values are the same
            Assert.AreEqual(AllStock.ThisStock, TestItem);
        }
Esempio n. 5
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        clsStock AStock = new clsStock();

        string ProductDescription = txtProductDescription.Text;
        string Price         = txtPrice.Text;
        string StockQuantity = txtStockQuantity.Text;
        string DateListed    = txtDateListed.Text;
        string Error         = "";

        Error = AStock.Valid(ProductDescription, DateListed, StockQuantity, Price);
        if (Error == "")
        {
            AStock.ProductDescription = ProductDescription;
            AStock.Price         = Convert.ToDecimal(Price);
            AStock.StockQuantity = Convert.ToInt32(StockQuantity);
            AStock.DateListed    = Convert.ToDateTime(DateListed);

            AStock.InStock = chkInStock.Checked;
            clsStockCollection StockList = new clsStockCollection();
            if (ProductID == -1)
            {
                StockList.ThisStock = AStock;
                StockList.Add();
            }
            else
            {
                StockList.ThisStock.Find(ProductID);
                StockList.ThisStock = AStock;
                StockList.Update();
            }
            Response.Redirect("StockList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
        public void UpdateMethodOK()
        {
            clsStockCollection Allstock = new clsStockCollection();

            clsStock TestItem = new clsStock();

            Int32 PrimaryKey = 0;

            
            TestItem.Clearence = true;
            TestItem.Description = "AddMethodExample";
            TestItem.Price = 9999.99;
            TestItem.Pristine = 12;
            TestItem.Non_Pristine = 15;
            TestItem.Next_Intake = DateTime.Now.Date;

            Allstock.ThisStock = TestItem;

            PrimaryKey = Allstock.Add();

            TestItem.Product_Code = PrimaryKey;

            TestItem.Clearence = true;
            TestItem.Description = "AddMethodExampleChanged";
            TestItem.Price = 1234.99;
            TestItem.Pristine = 14;
            TestItem.Non_Pristine = 23;
            TestItem.Next_Intake = DateTime.Now.Date;

            Allstock.ThisStock = TestItem;

            Allstock.Update();

            Allstock.ThisStock.Find(PrimaryKey);

            Assert.AreEqual(Allstock.ThisStock, TestItem);

        }
Esempio n. 7
0
        public void ReportByStockDescriptionTestDataFound()
        {
            clsStockCollection FilteredStock = new clsStockCollection();
            Boolean            OK            = true;

            FilteredStock.ReportByStockDescription("yyy yyy");
            if (FilteredStock.Count == 2)
            {
                if (FilteredStock.StockList[0].StockNo != 1)
                {
                    OK = false;
                }
                if (FilteredStock.StockList[1].StockNo != 21)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsFalse(OK);
        }
Esempio n. 8
0
        public void ReportByBookNameTestDataFound()
        {
            clsStockCollection FilteredStock = new clsStockCollection();
            Boolean            OK            = true;

            FilteredStock.ReportByBookName("Harry Potter and the Deathly Hallows");
            if (FilteredStock.Count == 2)
            {
                if (FilteredStock.StockList[0].BookID != 9780545010221)
                {
                    OK = false;
                }
                if (FilteredStock.StockList[1].BookID != 9780545010221)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Esempio n. 9
0
        public void ReportByProductDescriptTestDataFound()
        {
            clsStockCollection FilteredStock = new clsStockCollection();
            Boolean            OK            = true;

            FilteredStock.ReportByProductDescript("yyy yyy");
            if (FilteredStock.Count == 2)
            {
                if (FilteredStock.StockList[0].ProductNo != 36)
                {
                    OK = false;
                }
                if (FilteredStock.StockList[1].ProductNo != 37)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Esempio n. 10
0
        public void ReportByProductNoTestDataFound()
        {
            clsStockCollection FilteredProducts = new clsStockCollection();
            Boolean            OK = true;

            FilteredProducts.ReportByProductNo("XXX XXX");
            if (FilteredProducts.Count == 1)
            {
                if (FilteredProducts.mProductList[1].ProductNo != 1)
                {
                    OK = false;
                }
                if (FilteredProducts.mProductList[2].ProductNo != 6)
                {
                    OK = false;
                }
                else
                {
                    OK = false;
                }
                Assert.IsTrue(OK);
            }
        }
Esempio n. 11
0
        public void AddMethodOkay()
        {
            clsStockCollection allStock = new clsStockCollection();
            clsStock           aBook    = new clsStock();
            int PrimaryKey = 0;

            aBook.ISBN         = "88888888888888";
            aBook.BookName     = "testbook";
            aBook.Author       = "Terry Pratchett";
            aBook.OnOrder      = false;
            aBook.StockLevel   = 100;
            aBook.Price        = 9.99;
            aBook.SupplierID   = 1;
            aBook.ReleaseDate  = Convert.ToDateTime("25/9/2004");
            allStock.ThisStock = aBook;
            PrimaryKey         = allStock.Add();

            allStock.ThisStock.Find(PrimaryKey);
            Assert.AreEqual(allStock.ThisStock, aBook);
            //prevents the data being left in the table and failing future tests due to unique isbn constraint
            allStock.ThisStock.Find(PrimaryKey);
            allStock.Delete();
        }
Esempio n. 12
0
        public void FilterBySupplierTestDataFound()
        {
            clsStockCollection filteredStock = new clsStockCollection();
            Boolean            OK            = true;

            filteredStock.FilterBySupplier(2);
            if (filteredStock.Count == 2)
            {
                if (filteredStock.StockList[0].StockID != 2)
                {
                    OK = false;
                }
                if (filteredStock.StockList[1].StockID != 14)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Esempio n. 13
0
        public void ReportByBookNameTestDataFound()
        {
            clsStockCollection filteredStock = new clsStockCollection();
            Boolean            OK            = true;

            filteredStock.ReportByBookName("Going");
            if (filteredStock.Count == 2)
            {
                if (filteredStock.StockList[0].StockID != 7)
                {
                    OK = false;
                }
                if (filteredStock.StockList[1].StockID != 14)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Esempio n. 14
0
        public void ReportByClothesDescriptionTestDataFound()
        {
            clsStockCollection FilteredStocks = new clsStockCollection();
            Boolean            OK             = true;

            FilteredStocks.ReportByClothesDescription("xxx");
            if (FilteredStocks.Count == 2)
            {
                if (FilteredStocks.StockList[0].ClothesNo != 37)
                {
                    OK = false;
                }
                if (FilteredStocks.StockList[1].ClothesNo != 37)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
        public void ReoprtByPartDescriptionTestDataFound()
        {
            clsStockCollection FilteredStock = new clsStockCollection();
            Boolean            OK            = true;

            FilteredStock.ReoprtByPartDescription("xxxxxxxxxxxxxxx");
            if (FilteredStock.Count == 2)
            {
                if (FilteredStock.StockList[0].PartNo != 36)
                {
                    OK = false;
                }
                if (FilteredStock.StockList[1].PartNo != 37)
                {
                    OK = false;
                }
                else
                {
                    OK = false;
                }
                Assert.IsTrue(OK);
            }
        }
Esempio n. 16
0
        public void ReportByBookNameTestDataFound()
        {
            clsStockCollection FilterStocks = new clsStockCollection();
            Boolean            OK           = true;

            FilterStocks.ReportbyBookName("Wakanda");
            if (FilterStocks.Count == 2)
            {
                if (FilterStocks.StockList[0].ProductID != 326)
                {
                    OK = false;
                }
                if (FilterStocks.StockList[1].ProductID != 330)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Esempio n. 17
0
        public void UpdateMethodOK()
        {
            clsStockCollection AllProducts = new clsStockCollection();
            clsStock           TestItem    = new clsStock();
            Int32 PrimaryKey = 0;

            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.LimitedEdition    = false;
            TestItem.StyleName         = "Updated Test Style Name";
            TestItem.Price             = 59.99;
            TestItem.QuantityAvailable = 150;
            TestItem.BackInStockDate   = DateTime.Now.Date;
            AllProducts.ThisProduct    = TestItem;
            AllProducts.Update();
            AllProducts.ThisProduct.Find(PrimaryKey);
            Assert.AreEqual(AllProducts.ThisProduct, TestItem);
        }
Esempio n. 18
0
        public void StockListOk()
        {
            //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 the test
            clsStock TestItem = new clsStock();

            //set its properties
            TestItem.PhoneID          = 1;
            TestItem.PhoneMake        = "s";
            TestItem.PhoneModel       = "s";
            TestItem.PhoneDescription = "s";
            //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.StockList, TestList);
        }
        public void StockListOK()
        {
            clsStockCollection AllStock = new clsStockCollection();

            List<clsStock> TestList = new List<clsStock>();

            clsStock TestItem = new clsStock();

            TestItem.Product_Code = 1;
            TestItem.Clearence = true;
            TestItem.Description = "example";
            TestItem.Price = 9999.99;
            TestItem.Pristine = 12;
            TestItem.Non_Pristine = 15;
            TestItem.Next_Intake = DateTime.Now.Date;

            TestList.Add(TestItem);

            AllStock.StockList = TestList;

            Assert.AreEqual(AllStock.StockList, TestList);

        }
Esempio n. 20
0
    protected void btnApplyDate_Click(object sender, EventArgs e)
    {
        try
        {
            DateTime ReleaseDate = Convert.ToDateTime(txtReleaseDate.Text);

            clsStockCollection StockCollection = new clsStockCollection();

            StockCollection.FilterByDate(ReleaseDate);

            lstStockCollection.DataSource = StockCollection.StockList;

            lstStockCollection.DataValueField = "productId";

            lstStockCollection.DataTextField = "GameTitle";

            lstStockCollection.DataBind();
        }
        catch
        {
            lblError.Text = "Please enter a date";
        }
    }
Esempio n. 21
0
    protected void btnApplyPrice_Click(Object sender, EventArgs e)
    {
        try
        {
            Int32 FilteredPrice = Convert.ToInt32(txtPrice.Text);

            clsStockCollection StockCollection = new clsStockCollection();

            StockCollection.FilterByPrice(FilteredPrice);

            lstStockCollection.DataSource = StockCollection.StockList;

            lstStockCollection.DataValueField = "productId";

            lstStockCollection.DataTextField = "GameTitle";

            lstStockCollection.DataBind();
        }
        catch
        {
            lblError.Text = "Please enter a Number";
        }
    }
Esempio n. 22
0
    protected void btnApplyStockQ_Click(object sender, EventArgs e)
    {
        try
        {
            int mStockQ = Convert.ToInt32(txtStockQuantity.Text);

            clsStockCollection StockCollection = new clsStockCollection();

            StockCollection.FilterByStockQuantity(mStockQ);

            lstStockCollection.DataSource = StockCollection.StockList;

            lstStockCollection.DataValueField = "productId";

            lstStockCollection.DataTextField = "GameTitle";

            lstStockCollection.DataBind();
        }
        catch
        {
            lblError.Text = "Please Enter a Number";
        }
    }
    private void DisplayStock()

    {
        clsStockCollection StockBook = new clsStockCollection();

        StockBook.ThisStock.Find(ProductId);

        //display data for the record

        txtProductId.Text = StockBook.ThisStock.ProductId.ToString();

        txtProductName.Text = StockBook.ThisStock.ProductName;

        txtProductDescription.Text = StockBook.ThisStock.ProductDescription;

        txtPrice.Text = StockBook.ThisStock.Price.ToString();

        txtInStock.Text = StockBook.ThisStock.InStock.ToString();

        txtLastRestockDate.Text = StockBook.ThisStock.LastRestockDate.ToString();

        txtStockVariants.Text = StockBook.ThisStock.StockVariants.ToString();
    }
Esempio n. 24
0
        public void ListAndCountOK()
        {
            //create an instance of the class I want to create
            clsStockCollection AllStocks = new clsStockCollection();
            //create test data to assign to the property
            //for the collection class the data is a list of objects
            List <clsStock> TestList = new List <clsStock>();
            //add an item to the list
            //create item test data
            clsStock TestItem = new clsStock();

            //set the properties
            TestItem.Name           = "Example";
            TestItem.Description    = "Some item info";
            TestItem.StockQuantity  = 1;
            TestItem.StockItemPrice = 1;
            //add item to Test List
            TestList.Add(TestItem);
            //assign the data to the property
            AllStocks.StockList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllStocks.Count, TestList.Count);
        }
Esempio n. 25
0
        public void AddMethodOk()
        {
            clsStockCollection allStock = new clsStockCollection();

            clsStock testStock = new clsStock();

            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);

            string primaryKey = "";


            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);

            Assert.AreEqual(allStock.thisStock, testStock);
        }
        public void UpdateMethodOk()
        {
            clsStockCollection StockCollection = new clsStockCollection();

            clsStock TestGame = new clsStock();

            Int32 PrimaryKey = 0;

            TestGame.GameTitle     = "Test Update";
            TestGame.Platform      = "Playstation 2";
            TestGame.Price         = 40;
            TestGame.ReleaseDate   = DateTime.Now.Date;
            TestGame.InStock       = true;
            TestGame.StockQuantity = 20;

            StockCollection.ThisGame = TestGame;

            PrimaryKey = StockCollection.Add();

            TestGame.productId = PrimaryKey;

            TestGame.GameTitle     = "Test Update Ok";
            TestGame.Platform      = "Playstation 3";
            TestGame.Price         = 45;
            TestGame.ReleaseDate   = DateTime.Now.Date;
            TestGame.InStock       = true;
            TestGame.StockQuantity = 25;

            StockCollection.ThisGame = TestGame;

            StockCollection.Update();

            StockCollection.ThisGame.Find(PrimaryKey);

            Assert.AreEqual(StockCollection.ThisGame, TestGame);
        }
Esempio n. 27
0
        public void AddMethodOK()
        {
            //create an nstance for theclass we want to screate
            clsStockCollection AllStocks = 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.Availability = true;
            TestItem.CarModel     = "Mercedes A Class Test ADD function";
            TestItem.BHP          = "420 BHP";
            TestItem.Price        = 1;
            TestItem.DateAdded    = DateTime.Now.Date;
            //Setup the his address to test data
            AllStocks.ThisStock = TestItem;
            //add the record
            PrimaryKey = AllStocks.Add();
            //find the record
            AllStocks.ThisStock.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllStocks.ThisStock, TestItem);
        }
Esempio n. 28
0
        public void UpdateMethodOK()
        {
            //create an instance of the class I want to create
            clsStockCollection AllStocks = new clsStockCollection();
            //create test data
            clsStock TestItem = new clsStock();
            //variable to store the primary key
            Int32 PrimaryKey = 0;

            //set the properties
            TestItem.StockID        = 1;
            TestItem.Name           = "Example";
            TestItem.Description    = "Some item info";
            TestItem.StockQuantity  = 1;
            TestItem.StockItemPrice = 1;
            //set ThisStock to the test data
            AllStocks.ThisStock = TestItem;
            //add the record
            PrimaryKey = AllStocks.Add();
            //set the primary of the test data
            TestItem.StockID = PrimaryKey;
            //edit the test data
            TestItem.StockID        = 1;
            TestItem.Name           = "NewExample";
            TestItem.Description    = "New item info";
            TestItem.StockQuantity  = 1;
            TestItem.StockItemPrice = 1;
            //set the record based on the new test data
            AllStocks.ThisStock = TestItem;
            //update the record
            AllStocks.Update();
            //find the record
            AllStocks.ThisStock.Find(PrimaryKey);
            //test to see ThisStock matches the test data
            Assert.AreEqual(AllStocks.ThisStock, TestItem);
        }
Esempio n. 29
0
        public void StockListOK()
        {
            //this creates an instance of the class we want to create
            clsStockCollection Stock = new clsStockCollection();
            //create some test data to assign the property
            //this time it needs to be a list type of data
            List <clsStock> TestStockList = new List <clsStock>();
            //add an item to the list
            //create the item of test data
            clsStock TestItem = new clsStock();

            //set the properties
            TestItem.ItemNo    = 1;
            TestItem.ItemName  = "Overwatch";
            TestItem.Genre     = "First Person Shooter";
            TestItem.AgeRating = 13;
            TestItem.Condition = "Good";
            //add the item to the test list
            TestStockList.Add(TestItem);
            //assign the data to the property
            Stock.AllStock = TestStockList;
            //test to see if it exists
            Assert.AreEqual(Stock.Count, TestStockList.Count);
        }
        public void AddMethodOK()
        {
            clsStockCollection allStock = new clsStockCollection();

            clsStock testItem = new clsStock();

            Int32 PrimaryKey = 0;

            testItem.StockID           = 1;
            testItem.StockAvailability = 10;
            testItem.StockDescription  = "Comic Book";
            testItem.StockPrice        = 9.99;
            testItem.IsBeingRestocked  = true;

            allStock.ThisStock = testItem;

            PrimaryKey = allStock.Add();

            testItem.StockID = PrimaryKey;

            allStock.ThisStock.Find(PrimaryKey);

            Assert.AreEqual(allStock.ThisStock, testItem);
        }