Ejemplo n.º 1
0
        public static void SampleData()
        {
            try
            {
                Staff teacher = new Staff("Neil Urqhart", "C59 Merchiston", "*****@*****.**", 9253, "Software Engineering", "Lecturer");
                StaffList.Add(teacher);

                Module subject = new Module("Software Dev 2", "SET08108", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Ben Kenwright", "C48 Merchiston", "*****@*****.**", 9876, "Digital Media", "Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Computer Graphics", "IMD09132", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Brian Davidson", "C56 Merchiston", "*****@*****.**", 9267, "Computing", "Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Database Systems", "INF08104", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Andrew Cumming", "C39 Merchiston", "*****@*****.**", 9112, "Software Engineering", "Senior Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Web Technologies", "SET08101", teacher);
                ModuleList.Add(subject);

                teacher = new Staff("Sally Smith", "C66 Merchiston", "*****@*****.**", 9005, "Computing", "Senior Lecturer");
                StaffList.Add(teacher);

                subject = new Module("Mobile Apps", "SET08114", teacher);
                ModuleList.Add(subject);

                Student pupil = new Student("Bill Grimes", "22 Houslane", "*****@*****.**", 1020);
                StudentList.Add(pupil);

                pupil = new Student("Sophie Jackson", "6/6 Longstreet", "*****@*****.**", 1453);
                StudentList.Add(pupil);

                pupil = new Student("Jim Watt", "37 Dell AV", "*****@*****.**", 4532);
                StudentList.Add(pupil);

                pupil = new Student("Helen Doul", "6 Mainstreet", "*****@*****.**", 4562);
                StudentList.Add(pupil);

                pupil = new Student("Jannet Mole", "15 Crossdale", "*****@*****.**", 8763);
                StudentList.Add(pupil);
            }
            catch (ArgumentNullException)
            {

            }
            catch (ArgumentOutOfRangeException)
            {

            }
         

        }
Ejemplo n.º 2
0
 public void CreateValidStudentInstance()
 {
     //arrange
     string name = "Joe Blogs";
     string address = "23 Houselane";
     string email = "*****@*****.**";
     int matric = 1000;
     int expectedNoOfMatric = 1;
     //act
     Student validStudent = new Student(name, address, email, matric);
     //assert
     int actualNoOfMatric = Student.UsedMatricNumbers.Count;
     Assert.AreEqual(expectedNoOfMatric, actualNoOfMatric, 0, "incorrect number of matriculation numbers");
 }
Ejemplo n.º 3
0
 public void StudentCreationBlankEmail_ShouldThrowNullException()
 {
     //arrange
     string name = "Joe Blogs";
     string address = "23 Houselane";
     string email = "";
     int matric = 1003;
     //act
     try
     {
         //assert
         Student validStudent = new Student(name, address, email, matric);
     }
     catch (ArgumentNullException e)
     {
         StringAssert.Contains(e.Message, Student.BlankEmailMessage);
         return;
     }
     Assert.Fail("no exception thrown");
 }
 //conformation button handler
 private void btnConf_Click(object sender, RoutedEventArgs e)
 {
     //method varibles
     string name, address, email;
     int matNumber;
     //if any of the textboxes are invalid
     if ((validName != true) || (validAddress != true) || (validEmail != true) || (validMatric != true))
     {
         //show error meesage
         invForm = invName + invAdd + invEmail + invMat;
         MessageBox.Show("invalid form\n" + invForm);
     }
     else
     {
         //create new student and add to university
         name = txtName.Text;
         address = txtAddress.Text;
         email = txtEmail.Text;
         matNumber = Convert.ToInt32(txtMatric.Text);
         Student newStud = new Student(name, address, email, matNumber);
         University.StudentList.Add(newStud);
         this.Close();
     }
 }
Ejemplo n.º 5
0
 public void StudentCreationEmailHasNoAt_ShuoldThrowOutOfRange()
 {
     //arrange
     string name = "Joe Blogs";
     string address = "23 Houselane";
     string email = "j.blogsATmnapier.ac.uk";
     int matric = 10004;
     //act
     try
     {
         //assert
         Student validStudent = new Student(name, address, email, matric);
     }
     catch (ArgumentOutOfRangeException e)
     {
         StringAssert.Contains(e.Message, Student.EmailHasNoAt);
         return;
     }
     Assert.Fail("no exception thrown");
 }
Ejemplo n.º 6
0
 public void StudentCreationMatricGreaterThan9000_ShouldThrowOutOfRange()
 {
     //arrange
     string name = "Joe Blogs";
     string address = "23 Houselane";
     string email = "*****@*****.**";
     int matric = 9001;
     //act
     try
     {
         //assert
         Student validStudent = new Student(name, address, email, matric);
     }
     catch (ArgumentOutOfRangeException e)
     {
         StringAssert.Contains(e.Message, Student.MatricOutwithRangeMessage);
         return;
     }
     Assert.Fail("no exception thrown");
 }