Exemplo n.º 1
0
        public void ListAndCountOK()
        {
            //create an instance of the class we want to create
            clsItemCollection AllItems = new clsItemCollection();
            //create some test data to assign to the property
            List <clsStock> TestList = new List <clsStock>();
            //add items to the list
            //create the item of test data
            clsStock TestItem = new clsStock();

            //Set its properties
            TestItem.Available     = true;
            TestItem.ItemName      = "TestItem";
            TestItem.ItemType      = "Monitor";
            TestItem.StockQuantity = 10;
            TestItem.Price         = 10.00;
            TestItem.Supplier      = "KappaInc";
            TestItem.NextRestock   = DateTime.Now.Date.AddDays(1);
            //Add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllItems.ItemList = TestList;
            //Test to see that the two values are the same
            Assert.AreEqual(AllItems.Count, TestList.Count);
        }
Exemplo n.º 2
0
        public void AddMethodOK()
        {
            clsItemCollection AllItems   = new clsItemCollection();
            clsStock          TestItem   = new clsStock();
            Int32             PrimaryKey = 0;

            //set properties
            TestItem.ItemID        = 10; //This will only work once because it adds the test item to the list meaning there is now a duplicate, so change this value each time or remove it from the database
            TestItem.Available     = true;
            TestItem.ItemName      = "TestItem";
            TestItem.ItemType      = "Monitor";
            TestItem.StockQuantity = 10;
            TestItem.Price         = 10.00;
            TestItem.Supplier      = "KappaInc";
            TestItem.NextRestock   = DateTime.Now.Date.AddDays(1);
            //set ThisItem to the test data
            AllItems.ThisItem = TestItem;
            //add the record
            PrimaryKey = AllItems.Add();
            //set the primary key of the test data
            TestItem.ItemID = PrimaryKey;
            //find the record
            AllItems.ThisItem.Find(PrimaryKey);
            //test to see that the two values are the same
            Assert.AreEqual(AllItems.ThisItem, TestItem);
        }
Exemplo n.º 3
0
        public void ReportByItemTypeNoneFound()
        {
            clsItemCollection FilteredItems = new clsItemCollection();

            FilteredItems.ReportByItemType("xxxxxxx");
            Assert.AreEqual(0, FilteredItems.Count);
        }
Exemplo n.º 4
0
        public void ReportByItemTypeMethodOK()
        {
            clsItemCollection AllItems      = new clsItemCollection();
            clsItemCollection FilteredItems = new clsItemCollection();

            FilteredItems.ReportByItemType("");
            Assert.AreEqual(AllItems.Count, FilteredItems.Count);
        }
Exemplo n.º 5
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsItemCollection AllItems = new clsItemCollection();

            //test to see that it exists
            Assert.IsNotNull(AllItems);
        }
Exemplo n.º 6
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsItemCollection Items = new clsItemCollection();

        Items.ReportByItemType(txtFilter.Text);
        lstStockList.DataSource     = Items.ItemList;
        lstStockList.DataValueField = "ItemID";
        lstStockList.DataTextField  = "ItemName";
        lstStockList.DataBind();
    }
    protected void btnYes_Click1(object sender, EventArgs e)
    {
        //create a new instance of the item list
        clsItemCollection ItemList = new clsItemCollection();

        //find the record to delete
        ItemList.ThisItem.Find(ItemID);
        //delete the record
        ItemList.Delete();
        //redirect back to the main page
        Response.Redirect("StockList.aspx");
    }
Exemplo n.º 8
0
    void DisplayStock()
    {
        //create an instance of the Item Collection
        clsItemCollection AllItems = new clsItemCollection();

        //set the data source to the list of items in the collection
        lstStockList.DataSource = AllItems.ItemList;
        //set the name of the primary key
        lstStockList.DataValueField = "ItemID";
        //set the data field to display
        lstStockList.DataTextField = "ItemName";
        //bind the data to the list
        lstStockList.DataBind();
    }
Exemplo n.º 9
0
    protected void btnOK_Click1(object sender, EventArgs e)
    {
        //create a new instance of clsStock
        clsStock someStock = new clsStock();
        //capture the inputs as strings

        String ItemName      = txtItemName.Text;
        String ItemType      = txtItemType.Text;
        String StockQuantity = txtStockQuantity.Text;
        String Price         = txtPrice.Text;
        String Supplier      = txtSupplier.Text;
        String NextRestock   = txtNextRestock.Text;
        String Error         = "";

        // validate the data
        Error = someStock.Valid(ItemName, ItemType, StockQuantity, Price, Supplier, NextRestock);
        if (Error == "")//If it was fine collect the data
        {
            someStock.ItemID        = ItemID;
            someStock.ItemName      = ItemName;
            someStock.ItemType      = ItemType;
            someStock.StockQuantity = Int32.Parse(StockQuantity);
            someStock.Price         = Double.Parse(Price);
            someStock.Supplier      = Supplier;
            someStock.NextRestock   = Convert.ToDateTime(NextRestock);
            //create a new instance of item collection
            clsItemCollection ItemList = new clsItemCollection();
            //if this is a new record i.e. ItemID = -1 then add the data
            if (someStock.ItemID == -1)
            {
                someStock.ItemID  = Int32.Parse(txtItemID.Text);
                ItemList.ThisItem = someStock;

                ItemList.Add();
            }
            //otherwise it must be an update
            else
            {
                ItemList.ThisItem.Find(someStock.ItemID);
                ItemList.ThisItem = someStock;
                ItemList.Update();
            }
            Response.Redirect("StockList.aspx");
        }
        else
        {
            lblError.Text = Error;
        }
    }
Exemplo n.º 10
0
        public void ThisItemPropertyOK()
        {
            clsItemCollection AllItems = new clsItemCollection();
            clsStock          TestItem = new clsStock();

            TestItem.Available     = true;
            TestItem.ItemName      = "TestItem";
            TestItem.ItemType      = "Monitor";
            TestItem.StockQuantity = 10;
            TestItem.Price         = 10.00;
            TestItem.Supplier      = "KappaInc";
            TestItem.NextRestock   = DateTime.Now.Date.AddDays(1);
            AllItems.ThisItem      = TestItem;
            Assert.AreEqual(AllItems.ThisItem, TestItem);
        }
Exemplo n.º 11
0
    void DisplayItems()
    {
        //create an instace of the item collection
        clsItemCollection AllItems = new clsItemCollection();

        //find the record to update
        AllItems.ThisItem.Find(ItemID);
        //display the data for this record
        txtItemID.Text        = AllItems.ThisItem.ItemID.ToString();
        txtItemName.Text      = AllItems.ThisItem.ItemName;
        txtItemType.Text      = AllItems.ThisItem.ItemType;
        txtStockQuantity.Text = AllItems.ThisItem.StockQuantity.ToString();
        txtPrice.Text         = AllItems.ThisItem.Price.ToString();
        chkAvailable.Checked  = AllItems.ThisItem.Available;
        txtSupplier.Text      = AllItems.ThisItem.Supplier;
        txtNextRestock.Text   = AllItems.ThisItem.NextRestock.ToString();
    }
Exemplo n.º 12
0
        public void ReportByItemTypeDataFound()
        {
            clsItemCollection FilteredItems = new clsItemCollection();
            Boolean           OK            = true;

            FilteredItems.ReportByItemType("Mouse");
            if (FilteredItems.Count == 2)
            {
                if (FilteredItems.ItemList[0].ItemID != 1)
                {
                    OK = false;
                }
                if (FilteredItems.ItemList[1].ItemID != 11)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }