Exemplo n.º 1
0
        public void FilterByCategoryFoundOk()
        {
            //creates an instance of filtered data
            clsStockCollection filteredStock = new clsStockCollection();
            Boolean            OK            = true;

            filteredStock.FilterByCategory("xx");
            //checks if correct number of records found
            if (filteredStock.Count == 2)
            {
                if (filteredStock.StockList[0].ProductId != 3)
                {
                    OK = false;
                }
                if (filteredStock.StockList[1].ProductId != 6)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }
Exemplo n.º 2
0
        public void FilterByCategoryNoneFoundOk()
        {
            //creates an instance of filtered data
            clsStockCollection filteredStock = new clsStockCollection();

            filteredStock.FilterByCategory("XXX XX");
            Assert.AreEqual(0, filteredStock.Count);
        }
Exemplo n.º 3
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsStockCollection stocks = new clsStockCollection();

        stocks.FilterByCategory(tbCategory.Text);
        lstStock.DataSource = stocks.StockList;
        //set name of primary key
        lstStock.DataValueField = "ProductId";
        // set name of field to display
        lstStock.DataTextField = "Category";
        // bind data to list
        lstStock.DataBind();
    }
Exemplo n.º 4
0
    protected void btnClear_Click(object sender, EventArgs e)
    {
        clsStockCollection stocks = new clsStockCollection();

        stocks.FilterByCategory("");
        //clear any existing filter
        tbCategory.Text     = "";
        lstStock.DataSource = stocks.StockList;
        //set name of primary key
        lstStock.DataValueField = "ProductId";
        // set name of field to display
        lstStock.DataTextField = "Name";
        // bind data to list
        lstStock.DataBind();
    }