示例#1
0
        public void ReportByProductIdTestDataFound()
        {
            //create an instance of the filtered data
            clsOrderCollection FilteredOrders = new clsOrderCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a ProductId that doesn't exist
            FilteredOrders.ReportByProductId("24d");
            //check that the correct number of records are found
            if (FilteredOrders.Count == 2)
            {
                //check that the first record is ID 2
                if (FilteredOrders.OrderList[0].OrderId != 2)
                {
                    OK = false;
                }
                //check that the first record is ID 9
                if (FilteredOrders.OrderList[1].OrderId != 9)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
示例#2
0
        public void ReportByProductIdNoneFound()
        {
            //create an instance of the filtered data
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            //apply a Product Id that doesn't exist
            FilteredOrders.ReportByProductId("xxx");
            //test to see that tthere are no records
            Assert.AreEqual(0, FilteredOrders.Count);
        }
示例#3
0
        public void ReportByProductIdOK()
        {
            //create an instance of the class containing unfiltered results
            clsOrderCollection AllOrders = new clsOrderCollection();
            //create an instance of the filtered data
            clsOrderCollection FilteredOrders = new clsOrderCollection();

            //apply a blank string (should return all records)
            FilteredOrders.ReportByProductId("");
            //test to see that the two values are the same
            Assert.AreEqual(AllOrders.Count, FilteredOrders.Count);
        }
示例#4
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        //create an instance of the order collection
        clsOrderCollection Orders = new clsOrderCollection();

        Orders.ReportByProductId(txtFilter.Text);
        lstOrderList.DataSource = Orders.OrderList;
        //set the name of the primart key
        lstOrderList.DataValueField = "OrderId";
        //set the name of the field to display
        lstOrderList.DataTextField = "ProductId";
        //bind the data to the list
        lstOrderList.DataBind();
    }
示例#5
0
    protected void btnClear_Click(object sender, EventArgs e)
    {
        //create an instance of the order collection
        clsOrderCollection Orders = new clsOrderCollection();

        Orders.ReportByProductId("");
        //clear any existing filter to tidy up the interface
        txtFilter.Text          = "";
        lstOrderList.DataSource = Orders.OrderList;
        //set the name of the primary key
        lstOrderList.DataValueField = "OrderId";
        //set the name of the field to display
        lstOrderList.DataTextField = "ProductId";
        //bind the data to the list
        lstOrderList.DataBind();
    }