public void ReportByCustomerNameTestDataFound()
        {
            //create instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            //var to store outcome
            Boolean OK = true;

            //apply a customer name that exists
            FilteredCustomers.ReportByCustomerName("Alien");

            //check that the correct number of records are found
            if (FilteredCustomers.Count == 2)
            {
                //check that the first record CustomerId is 4
                if (FilteredCustomers.CustomerList[0].CustomerId != 4)
                {
                    OK = false;
                }
                //check that the first record CustomerId is 37
                if (FilteredCustomers.CustomerList[1].CustomerId != 37)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            //test to see if there are no records
            Assert.IsTrue(OK);
        }
    Int32 DisplayCustomers(string CustomerNameFilter)
    {
        Int32  CustomerID;        //var to store the primary key
        string CustomerName;      //var to store the customer name
        string CustomerTelNumber; //var to store the customer tel number
        string CustomerAddress;   // var to store the customer address
        //; //create an onstance of the customer book class
        //create an instance of the customer collection class
        clsCustomerCollection CustomerBook = new clsCustomerCollection();

        CustomerBook.ReportByCustomerName(CustomerNameFilter);
        Int32 RecordCount;                                                          // var to store the count of records
        Int32 Index = 0;                                                            // var to store the index for the loop

        RecordCount = CustomerBook.Count;                                           // get the count of records
        lstCustomers.Items.Clear();
        while (Index < RecordCount)                                                 // while there are records to process
        {
            CustomerID        = CustomerBook.CustomerList[Index].CustomerID;        // get the primary key
            CustomerName      = CustomerBook.CustomerList[Index].CustomerName;      // get the customer name
            CustomerTelNumber = CustomerBook.CustomerList[Index].CustomerTelNumber; // get the customer tel number
            CustomerAddress   = CustomerBook.CustomerList[Index].CustomerAddress;   // get the customeraddress
            //create a new entry for the list box
            ListItem NewEntry = new ListItem(CustomerName + " " + CustomerAddress + " " + CustomerTelNumber, CustomerID.ToString());
            lstCustomers.Items.Add(NewEntry); // ADD THE Customer TO THE LIST
            Index++;
        }
        return(RecordCount); //return the count of records found
    }
        public void ReportByCustomerNameNoneFound()
        {
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            FilteredCustomers.ReportByCustomerName("xxxxx xxxxx");
            Assert.AreEqual(0, FilteredCustomers.Count);
        }
        public void ReportbyCustomerNameTestDataFound()
        {
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomerName = new clsCustomerCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a customer name that doesnt exist
            FilteredCustomerName.ReportByCustomerName("yyy yyy");
            //check that the correct number of records are found
            if (FilteredCustomerName.Count == 2)
            {
                // {
                //   OK = false;

                //  }
                //check that the first record is ID 37
                if (FilteredCustomerName.CustomerList[0].CustomerID != 8)
                {
                    OK = false;
                }
                //check that the first record is ID 37
                if (FilteredCustomerName.CustomerList[1].CustomerID != 9)
                {
                    OK = false;
                }
            }

            else
            {
                OK = false;
            }
            //test to see that there are no records
            Assert.IsTrue(OK);
        }
        public void ReportByCustomerNameMethodOK()
        {
            clsCustomerCollection AllCustomers      = new clsCustomerCollection();
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            FilteredCustomers.ReportByCustomerName("");
            Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count);
        }
        public void ReportbyCustomerNameNoneFound()
        {
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomerName = new clsCustomerCollection();

            //test to see that the are no records;
            FilteredCustomerName.ReportByCustomerName("xxx xxx");
            //test to see that the two values are the same
            Assert.AreEqual(0, FilteredCustomerName.Count);
        }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        clsCustomerCollection Customers = new clsCustomerCollection();

        Customers.ReportByCustomerName(txtFilter.Text);
        lstCustomerList.DataSource     = Customers.CustomerList;
        lstCustomerList.DataValueField = "CustomerNumber";
        lstCustomerList.DataTextField  = "CustomerName";
        lstCustomerList.DataBind();
    }
        public void ReportByCustomerNameNoneFound()
        {
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            //apply a customer name that doesn't exist
            FilteredCustomers.ReportByCustomerName("Unexisting Person");

            //test to see if there are no records
            Assert.AreEqual(0, FilteredCustomers.Count);
        }
        public void ReportbyCustomerName()
        {
            //create an instance of the class we want to create
            clsCustomerCollection AllCustomers = new clsCustomerCollection();
            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomerName = new clsCustomerCollection();

            //apply a blank string (should return all record);
            FilteredCustomerName.ReportByCustomerName("");
            //test to see that the two values are the same
            Assert.AreEqual(AllCustomers.Count, FilteredCustomerName.Count);
        }
        public void ReportByCustomerNameMethodOK()
        {
            //create instance of of the class containing unfiltered results
            clsCustomerCollection AllCustomers = new clsCustomerCollection();

            //create an instance of the filtered data
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();

            //apply a blank string (should return all records)
            FilteredCustomers.ReportByCustomerName("");

            //test to see if the two values are the same
            Assert.AreEqual(AllCustomers.Count, FilteredCustomers.Count);
        }
Exemple #11
0
    protected void btnApply_Click(object sender, EventArgs e)
    {
        //create instcnace of clsCustomerCollection
        clsCustomerCollection AllCustomers = new clsCustomerCollection();

        AllCustomers.ReportByCustomerName(txtFilterCustomerName.Text);
        lstCustomerList.DataSource = AllCustomers.CustomerList;

        //set the name of the primary key
        lstCustomerList.DataValueField = "CustomerId";

        //set the name of the field to display
        lstCustomerList.DataTextField = "CustomerName";

        //bind the data to the list
        lstCustomerList.DataBind();
    }
Exemple #12
0
    protected void btnClear_Click(object sender, EventArgs e)
    {
        //create instcnace of clsCustomerCollection
        clsCustomerCollection AllCustomers = new clsCustomerCollection();

        AllCustomers.ReportByCustomerName("");

        //clear any existing filter to tidy up the interface
        txtFilterCustomerName.Text = "";
        lstCustomerList.DataSource = AllCustomers.CustomerList;

        //set the name of the primary key
        lstCustomerList.DataValueField = "CustomerId";

        //set the name of the field to display
        lstCustomerList.DataTextField = "CustomerName";

        //bind the data to the list
        lstCustomerList.DataBind();
    }
        public void ReportByCustomerNameTestDataFound(string v)
        {
            clsCustomerCollection FilteredCustomers = new clsCustomerCollection();
            Boolean OK = true;

            FilteredCustomers.ReportByCustomerName("xxxx xxxxx");
            if (FilteredCustomers.Count == 2)
            {
                if (FilteredCustomers.CustomerList[0].CustomerNumber != 7)
                {
                    OK = false;
                }
                if (FilteredCustomers.CustomerList[1].CustomerNumber != 8)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            Assert.IsTrue(OK);
        }