public void ListAndCountOk()
        {
            //create an instance of the class we want to create
            clsTutorCollection AllTutors = new clsTutorCollection();
            //create some test data to assign to the property
            //in this case the data needs to be a list of object
            List <clsTutor> TestList = new List <clsTutor>();
            //add an item to the list
            //create the item of test data
            clsTutor TestItem = new clsTutor();

            //set the properties of the test object
            TestItem.tutorAvailabe  = true;
            TestItem.tutorId        = 1;
            TestItem.tutorFirstName = "Bob";
            TestItem.tutorLastName  = "Bob";
            TestItem.tutorEmail     = "*****@*****.**";
            TestItem.tutorSubject   = "Chemistry";
            TestItem.tutorPassword  = "******";
            TestItem.tutorDateAdded = DateTime.Now.Date;

            //add the item to the list
            TestList.Add(TestItem);

            //assign the data to the property
            AllTutors.TutorList = TestList;
            //test to see that the two values are the same
            Assert.AreEqual(AllTutors.Count, TestList.Count);
        }
        public void UpdateMethodOk()
        {
            //create an instance of the class we want to create
            clsTutorCollection AllTutors = new clsTutorCollection();
            //create the tem of test data
            clsTutor TestItem = new clsTutor();
            //variable to store the primary key
            Int32 PrimaryKey = 0;


            //set the properties of the test object
            TestItem.tutorAvailabe  = true;
            TestItem.tutorId        = 1;
            TestItem.tutorFirstName = "Bob";
            TestItem.tutorLastName  = "Bob";
            TestItem.tutorEmail     = "*****@*****.**";
            TestItem.tutorSubject   = "Chemistry";
            TestItem.tutorPassword  = "******";
            TestItem.tutorDateAdded = DateTime.Now.Date;

            //set ThisTutor to the test data
            AllTutors.ThisTutor = TestItem;
            //update the record
            AllTutors.Update();
            //find the record
            AllTutors.ThisTutor.Find(PrimaryKey);
            //test to see if ThisTutor matches the test data
            Assert.AreEqual(AllTutors.ThisTutor, TestItem);
        }
示例#3
0
        public void InstanceOk()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();

            //test to see that it now exists
            Assert.IsNotNull(aTutor);
        }
示例#4
0
        public void TestIdTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            int TestData = 1;

            //assign the data to the tutor
            aTutor.tutorId = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorId, TestData);
        }
示例#5
0
        public void ValidationMethodOk()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            //test to see that result is correct
            Assert.AreEqual(Error, "");
        }
示例#6
0
        public void TestDateAddedTutor()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to the property
            DateTime TestData = DateTime.Now.Date;

            //assign the data to the property
            aTutor.tutorDateAdded = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorDateAdded, TestData);
        }
示例#7
0
        public void TestPasswordTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            string TestData = "12345678910";

            //assign the data to the tutor
            aTutor.tutorPassword = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorPassword, TestData);
        }
示例#8
0
        public void TestAvailabilityTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            Boolean TestData = true;

            //assign the data to the tutor
            aTutor.tutorAvailabe = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorAvailabe, TestData);
        }
示例#9
0
        public void TestNameTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            String TestData = "Bob";

            //assign the data to the tutor
            aTutor.tutorFirstName = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorFirstName, TestData);
        }
示例#10
0
        public void TestEmailTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            string TestData = "*****@*****.**";

            //assign the data to the tutor
            aTutor.tutorEmail = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorEmail, TestData);
        }
示例#11
0
        public void TestSubjectTutor()
        {
            //create instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //create some test data to assign to tutor
            string TestData = "Chemistry";

            //assign the data to the tutor
            aTutor.tutorSubject = TestData;
            //test to see that the two values are the same
            Assert.AreEqual(aTutor.tutorSubject, TestData);
        }
示例#12
0
    void DisplayTutor(Int32 TutorsId)
    {
        clsTutor myTutor = new clsTutor();

        myTutor.Find(TutorsId);

        txtTutorCertificateCount.Text        = Convert.ToString(myTutor.TutorCertificates);
        txtTutorFirstName.Text               = myTutor.TutorName;
        txtTutorLastName.Text                = myTutor.TutorSurname;
        txtTutorRegisteredOn.Text            = myTutor.TutorRegisterDate.ToString("dd/MM/yyyy");
        chkTutorEligible.Checked             = myTutor.TutorEligible;
        ddlTutorTeachingCourse.SelectedIndex = myTutor.TutorCourseNo - 1;
    }
示例#13
0
        public void FindMethodOK()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //boolean variable to store the result of the validation
            Boolean Found = false;
            //create some test data to assign to the property
            Int32 tutorId = 1;

            //invoke the method
            Found = aTutor.Find(tutorId);
            //test to see if the result is correct
            Assert.IsTrue(Found);
        }
示例#14
0
        public void TutorSubjectMinPlusOne()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";
            //creating some test data to pass the method
            string tutorEmail = "abcd"; //this should pass

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            //test to see that result is correct
            Assert.AreEqual(Error, "");
        }
示例#15
0
        public void TutorLastNameMaxLessOne()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";
            //creating some test data to pass the method
            string tutorLastName = ""; //this should pass

            tutorLastName = tutorLastName.PadRight(14, 'a');

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            Assert.AreEqual(Error, "");
        }
示例#16
0
        public void TutorPasswordExtremeMax()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";
            //creating some test data to pass the method
            string tutorPassword = "";

            tutorPassword = tutorPassword.PadRight(300, 'a'); //this should fail

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            //test to see that result is correct
            Assert.AreNotEqual(Error, "");
        }
示例#17
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        clsTutor ThisTutor = new clsTutor();
        string   ErrorMsg;

        ErrorMsg = ThisTutor.TutorValid(txtTutorFirstName.Text,
                                        txtTutorLastName.Text,
                                        txtTutorRegisteredOn.Text,
                                        txtTutorCertificateCount.Text);

        txtErrorMessage.Visible = true;

        if (ErrorMsg == "")
        {
            clsTutorCollection NewTutor = new clsTutorCollection();
            if (TutorId == -1)
            {
                NewTutor.ThisTutor.TutorName         = txtTutorFirstName.Text;
                NewTutor.ThisTutor.TutorSurname      = txtTutorLastName.Text;
                NewTutor.ThisTutor.TutorRegisterDate = Convert.ToDateTime(txtTutorRegisteredOn.Text);
                NewTutor.ThisTutor.TutorEligible     = chkTutorEligible.Checked;
                NewTutor.ThisTutor.TutorCertificates = Convert.ToInt32(txtTutorCertificateCount.Text);
                NewTutor.ThisTutor.TutorCourseNo     = ddlTutorTeachingCourse.SelectedIndex + 1;

                NewTutor.Add();
            }
            else
            {
                NewTutor.ThisTutor.TutorId           = TutorId;
                NewTutor.ThisTutor.TutorName         = txtTutorFirstName.Text;
                NewTutor.ThisTutor.TutorSurname      = txtTutorLastName.Text;
                NewTutor.ThisTutor.TutorRegisterDate = Convert.ToDateTime(txtTutorRegisteredOn.Text);
                NewTutor.ThisTutor.TutorEligible     = chkTutorEligible.Checked;
                NewTutor.ThisTutor.TutorCertificates = Convert.ToInt32(txtTutorCertificateCount.Text);
                NewTutor.ThisTutor.TutorCourseNo     = ddlTutorTeachingCourse.SelectedIndex + 1;

                NewTutor.Update();
            }
            Response.Redirect("Tutor.aspx");
        }
        else
        {
            txtErrorMessage.Text = ErrorMsg;
        }
    }
示例#18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Create a new instance of tutor
        clsTutor aTutor = new clsTutor();

        //Get the data from the session object
        aTutor = (clsTutor)Session["aTutor"];
        //display the tutor ID for this entry
        //Response.Write("<b> LOGIN SUCCESSFUL </b>");
        Response.Write(aTutor.tutorId);

        //Display what text is in each field
        lblFirstName.Text = aTutor.tutorFirstName;
        lblLastName.Text  = aTutor.tutorLastName;
        lblEmail.Text     = aTutor.tutorEmail;
        lblSubject.Text   = aTutor.tutorSubject;
        lblPassword.Text  = aTutor.tutorPassword;
        lblDateAdded.Text = Convert.ToString(aTutor.tutorDateAdded);
    }
示例#19
0
        public void DateAddedMin()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";
            //creating test variable to store test date
            DateTime TestDate;

            //set date to today
            TestDate = DateTime.Now.Date;// this should pass

            //have to convert date to string
            string DateAdded = TestDate.ToString();

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            //test to see that result is correct
            Assert.AreEqual(Error, "");
        }
示例#20
0
        public void DateAddedMinLessOne()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //string variable to store any error messages
            String Error = "";
            //creating test variable to store test date
            DateTime TestDate;

            //set date to today
            TestDate = DateTime.Now.Date;

            //change the date to today -1 day
            TestDate = TestDate.AddDays(-1); // this should fail

            //have to convert date to string
            string tutorDateAdded = TestDate.ToString();

            //invoke the method
            Error = aTutor.Valid(tutorFirstName, tutorLastName, tutorEmail, tutorSubject, tutorDateAdded, tutorPassword);
            Assert.AreNotEqual(Error, "");
        }
示例#21
0
        public void ThisTutorPropertyOk()
        {
            //create an instance of the class we want to create
            clsTutorCollection AllTutors = new clsTutorCollection();
            //create some test data to assign to the property
            clsTutor TestItem = new clsTutor();

            //set the properties of the test object
            TestItem.tutorAvailabe  = true;
            TestItem.tutorId        = 1;
            TestItem.tutorFirstName = "Bob";
            TestItem.tutorLastName  = "Bob";
            TestItem.tutorEmail     = "*****@*****.**";
            TestItem.tutorSubject   = "Chemistry";
            TestItem.tutorPassword  = "******";
            TestItem.tutorDateAdded = DateTime.Now.Date;

            //assign the data to the property
            AllTutors.ThisTutor = TestItem;
            //test to see that the two values are the same
            Assert.AreEqual(AllTutors.ThisTutor, TestItem);
        }
示例#22
0
        public void TestSubjectAddedFound()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assumes that it is)
            Boolean Ok = true;
            //create some test data to assign to use with the method
            Int32 tutorId = 1;

            //invoke the method
            Found = aTutor.Find(tutorId);

            //get subject from class and compare with expected result
            if (aTutor.tutorSubject != "Chemistry")
            {
                Ok = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(Ok);
        }
示例#23
0
        public void TestPasswordAddedFound()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assumes that it is)
            Boolean Ok = true;
            //create some test data to assign to use with the method
            Int32 tutorId = 1;

            //invoke the method
            Found = aTutor.Find(tutorId);

            //get password from class and compare with what the result should be
            if (aTutor.tutorPassword != "12345678910")
            {
                Ok = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(Ok);
        }
示例#24
0
        public void TestTutorNotFound()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assumes that it is)
            Boolean Ok = true;
            //create some test data to assign to use with the method
            Int32 tutorId = 1;

            //invoke the method
            Found = aTutor.Find(tutorId);

            //check the tutor id number
            if (aTutor.tutorId != 1)
            {
                Ok = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(Ok);
        }
示例#25
0
        public void TestDateAddedFound()
        {
            //create an instance of the class we want to create
            clsTutor aTutor = new clsTutor();
            //boolean variable to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK (assumes that it is)
            Boolean Ok = true;
            //create some test data to assign to use with the method
            Int32 tutorId = 1;

            //invoke the method
            Found = aTutor.Find(tutorId);

            //check the property
            if (aTutor.tutorDateAdded != Convert.ToDateTime("17/03/2020"))
            {
                Ok = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(Ok);
        }
示例#26
0
    protected void btnSignIn_Click(object sender, EventArgs e)
    {
        //create an instance of the tutor class
        clsTutor aTutor = new clsTutor();
        //variable to store the primary key
        Int32 tutorId;
        //variable to store the result of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        tutorId = Convert.ToInt32(txtTutorId.Text);

        //find the record
        Found = aTutor.Find(tutorId);

        //if record is found
        if (Found == true)
        {
            if (aTutor.tutorId == tutorId && aTutor.tutorPassword == txtTutorPassword.Text)
            {
                //store the data in the session object
                Session["tutorId"] = tutorId;
                //redirect to the edit page
                Response.Redirect("TutorPersonalDetails.aspx");

                //hide the error label as we encountered no errors
                lblError.Visible = false;
            }
            else //record not found
            {
                string Error = "The tutor with the ID number " + tutorId + " was not found or your Password is incorrect";
                //display the error message
                lblError.Text = "[" + Error + "]";
                //set label to visible
                lblError.Visible = true;
            }
        }
    }
示例#27
0
    protected void btnFind_Click(object sender, EventArgs e)
    {
        //create an instance of the tutor class
        clsTutor aTutor = new clsTutor();
        //variable to store the primary key
        Int32 tutorId;
        //variable to store the result of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        tutorId = Convert.ToInt32(txtTutorId.Text);

        //find the record
        Found = aTutor.Find(tutorId);
        //if record is found
        if (Found == true)
        {
            //display the values of the properties in the form
            txtFirstName.Text    = aTutor.tutorFirstName;
            txtLastName.Text     = aTutor.tutorLastName;
            txtEmail.Text        = aTutor.tutorEmail;
            txtSubject.Text      = aTutor.tutorSubject;
            chkAvailable.Checked = aTutor.tutorAvailabe;
            txtDateAdded.Text    = aTutor.tutorDateAdded.ToString();
            txtPassword.Text     = aTutor.tutorPassword;

            //hide the error label as we encountered no errors
            lblError.Visible = false;
        }
        else //record not found
        {
            string Error = "The record with the ID number " + tutorId + " was not found";
            //display the error message
            lblError.Text = "[" + Error + "]";
            //set label to visible
            lblError.Visible = true;
        }
    }
示例#28
0
        public void DeleteMethodOk()
        {
            //create an instance of the class we want to create
            clsTutorCollection AllTutors = new clsTutorCollection();
            //create the tem of test data
            clsTutor TestItem = new clsTutor();
            //variable to store the primary key
            Int32 PrimaryKey = 0;


            //set the properties of the test object
            TestItem.tutorAvailabe  = true;
            TestItem.tutorId        = 1;
            TestItem.tutorFirstName = "Bob";
            TestItem.tutorLastName  = "Bob";
            TestItem.tutorEmail     = "*****@*****.**";
            TestItem.tutorSubject   = "Chemistry";
            TestItem.tutorPassword  = "******";
            TestItem.tutorDateAdded = DateTime.Now.Date;

            //set ThisTutor to the test data
            AllTutors.ThisTutor = TestItem;
            //add the record
            PrimaryKey = AllTutors.Add();
            //set the primary key of the test data
            TestItem.tutorId = PrimaryKey;
            //find the record
            AllTutors.ThisTutor.Find(PrimaryKey);
            //delete this record
            AllTutors.Delete();
            //now find the record
            Boolean Found = AllTutors.ThisTutor.Find(PrimaryKey);

            //test to see that the two values are the same
            Assert.IsFalse(Found);
        }