Beispiel #1
0
        public void TestForCorrectSetPhoneNumber()
        {
            var register = new TeacherRegisterController();

            string PhoneNumber = "1234567890";

            register.SetPhone(PhoneNumber);
            var resultPhoneNumber = register.TeacherPhoneNumber;

            Assert.AreEqual("1234567890", resultPhoneNumber, "Correct set teacher PhoneNumber ");
        }
        //add  teacher in db and checks if info is correct
        void AddTeacherInDb()
        {
            //NAME
            try
            {
                teacherRegisterController.SetName(FullName);
                if (FullName.Split(' ').ToList().Count > 3)
                {
                    throw new Exception();
                }
                if (teacherRegisterController.TeacherNameExists(FullName))
                {
                    MessageBox.Show("Teacher already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch
            {
                MessageBox.Show("Wrong Name Format!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            // ADD BirthDate

            teacherRegisterController.AddBirthdate(Date);

            //Email
            if (teacherRegisterController.IsValidEmail(Email))
            {
                if (teacherRegisterController.CheckEmailExists(Email))
                {
                    teacherRegisterController.SetEmail(Email);
                }
                else
                {
                    MessageBox.Show("Email is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Email is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //ADD Phone
            if (teacherRegisterController.PhoneIsValid(PhoneNumber))
            {
                if (teacherRegisterController.CheckPhoneExists(PhoneNumber) == false)
                {
                    teacherRegisterController.SetPhone(PhoneNumber);
                }
                else
                {
                    MessageBox.Show("Phone number is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Phone number is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }



            //ADD EGN
            if (teacherRegisterController.IsValidEGN(EGN))
            {
                if (teacherRegisterController.CheckEGNExists(EGN) == false)
                {
                    teacherRegisterController.SetEGN(EGN);
                }
                else
                {
                    MessageBox.Show("EGN is already used!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("EGN is not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                if (Subject.SelectedItem == null)
                {
                    MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    teacherRegisterController.SetSubject(Subject.Text);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Please select a subject!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            teacherRegisterController.CommitChanged();
            MessageBox.Show("Success!", "Operation Completed", MessageBoxButtons.OK);
        }