Int32 DisplayProductName(string ProductNameFilter)
        {
            Int32  ProductNo;   // var to store the primary key
            string ProductName; // var to store the surname

            //create an instance of the address collection class
            clsProductCollection Product = new clsProductCollection();

            Product.ReportByProductName(ProductNameFilter);
            Int32 RecordCount;                                        // var to store the count of records
            Int32 Index = 0;                                          // var to store the index for the loop

            RecordCount = Product.Count;                              //get the count of records
            lstProduct.Items.Clear();
            while (Index < RecordCount)                               // while there are records to process
            {
                ProductNo   = Product.ProductList[Index].ProductNo;   //get the primary key
                ProductName = Product.ProductList[Index].ProductName; //get the Surnanme

                //create a new entry for the listbox
                ListItem NewEntry = new ListItem(ProductName, ProductNo.ToString());
                lstProduct.Items.Add(NewEntry);
                Index++;
            }
            return(RecordCount);//return the count of records found
        }
        public void ReportByProductNameNoneFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByProductName("abcdefg");
            Assert.AreEqual(0, FilteredProducts.Count);
        }
        public void ReportByProductNameMethodOK()
        {
            clsProductCollection Products         = new clsProductCollection();
            clsProductCollection FilteredProducts = new clsProductCollection();

            FilteredProducts.ReportByProductName("");
            Assert.AreEqual(Products.Count, FilteredProducts.Count);
        }
Esempio n. 4
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsProductCollection Products = new clsProductCollection();

        Products.ReportByProductName(txtNameSearch.Text);
        ProductListBox.DataSource     = Products.ProductList;
        ProductListBox.DataValueField = "ProductNo";
        ProductListBox.DataTextField  = "ProductName";
        ProductListBox.DataBind();
    }
        public void ReportByProductNameNoneFound()
        {
            //create an instance of the filtered data
            clsProductCollection FilteredProduct = new clsProductCollection();

            //apply a Product name that doesn't exist
            FilteredProduct.ReportByProductName("qqqqq");
            //test to see that there are no records
            Assert.AreEqual(0, FilteredProduct.Count);
        }
        public void ReportByProductNameOK()
        {
            //create an instance of the class containing unfiltered results
            clsProductCollection AllProducts = new clsProductCollection();
            //create an instance of the filtered data
            clsProductCollection FilteredProduct = new clsProductCollection();

            //apply a blank string(Should return all records);
            FilteredProduct.ReportByProductName("");
            //test to see that the two values are the same
            Assert.AreEqual(AllProducts.Count, FilteredProduct.Count);
        }
        public void ReportByProductNameFound()
        {
            clsProductCollection FilteredProducts = new clsProductCollection();
            Boolean OK = true;

            FilteredProducts.ReportByProductName("abcdef");
            if (FilteredProducts.Count == 2)
            {
                if (FilteredProducts.ProductList[0].ProductNo != 37)
                {
                    OK = false;
                }
                if (FilteredProducts.ProductList[1].ProductNo != 38)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            Assert.IsTrue(OK);
        }