Exemple #1
0
        public void ReportByGenderFound()
        {
            //create an instance of the filtered data
            clsTrainerCollection FilteredTrainers = new clsTrainerCollection();
            //var to store the outcome
            Boolean OK = true;

            //apply a gender that doesn't exist (but is in the database)
            FilteredTrainers.ReportByGender("TEST");
            //check that the correct number of records are found
            if (FilteredTrainers.Count == 2)
            {
                //check that the first record ID is 58
                if (FilteredTrainers.TrainerList[0].TrainerID != 58)
                {
                    OK = false;
                }
                //check that the second record ID is 59
                if (FilteredTrainers.TrainerList[1].TrainerID != 59)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }
            //test to to see the correct amount of records were shown
            Assert.IsTrue(OK);
        }
Exemple #2
0
        public void ReportByGenderNoneFound()
        {
            //create an instance of the filtered data
            clsTrainerCollection FilteredTrainers = new clsTrainerCollection();

            //apply a gender that doesnt exist
            FilteredTrainers.ReportByGender("Hello");
            //test to see that that there are no records
            Assert.AreEqual(0, FilteredTrainers.Count);
        }
Exemple #3
0
        public void ReportByGenderMethodOK()
        {
            //create an instance of the class containing unflitered results
            clsTrainerCollection AllTrainers = new clsTrainerCollection();
            //create  an instance of the filtered data
            clsTrainerCollection FilteredTrainers = new clsTrainerCollection();

            //apply a blank string (should return all records)
            FilteredTrainers.ReportByGender("");
            Assert.AreEqual(AllTrainers.Count, FilteredTrainers.Count);
        }
    protected void btnApply_Click(object sender, EventArgs e)
    {
        //create an instance of the trainer collection
        clsTrainerCollection Trainers = new clsTrainerCollection();

        Trainers.ReportByGender(txtFilter.Text);
        lstTrainerList.DataSource = Trainers.TrainerList;
        //set the name of the primary key
        lstTrainerList.DataValueField = "TrainerID";
        //set the name of the field to display
        lstTrainerList.DataTextField = "FullName";
        //bind the data to the list
        lstTrainerList.DataBind();
    }
    protected void btnClear_Click(object sender, EventArgs e)
    {
        //create an instance of the trainer collection
        clsTrainerCollection Trainers = new clsTrainerCollection();

        Trainers.ReportByGender("");
        //clear any existing filter to tidy up the interface
        lstTrainerList.DataSource     = Trainers.TrainerList;
        txtFilter.Text                = "";
        lstTrainerList.DataValueField = "TrainerID";
        //set the name of the field to display
        lstTrainerList.DataTextField = "FullName";
        //bind the data to the list
        lstTrainerList.DataBind();
    }