Beispiel #1
0
        public void CourseList_ThrowException_StudentAlreadyExists()
        {
            Course course = new Course("Math");

            int uniqueID = 11111;

            Student student = new Student("Ivan", uniqueID);
            Student student2 = new Student("Georgi", uniqueID);

            course.AddStudent(student);
            course.AddStudent(student2);
        }
Beispiel #2
0
        public void CourseList_ThrowException_MoreThan30Students()
        {
            Course course = new Course("Math");

            Random uniqueID = new Random();

            for (int i = 0; i < 50; i++)
            {
                Student student = new Student("Ivan", uniqueID.Next(10000, 99999));
                course.AddStudent(student);
            }
        }
Beispiel #3
0
 public void RemoveStudent(Student student)
 {
     for (int i = 0; i < StudentsInCourse.Count; i++)
     {
         if (StudentsInCourse[i].UniqueID == student.UniqueID)
         {
             studentsInCourse.Remove(student);
             Console.WriteLine("Student {0} removed.", student.Name);
             return;
         }
     }
     Console.WriteLine("Invalid remove operation. Student not found");
 }
Beispiel #4
0
        public void AddStudent(Student student)
        {
            if (StudentsInCourse.Count == 30)
            {
                throw new InvalidOperationException("The students are already 30. You must remove one, before you can add.");
            }

            for (int i = 0; i < StudentsInCourse.Count; i++)
            {
                if (StudentsInCourse[i].UniqueID == student.UniqueID)
                {
                    throw new InvalidOperationException("There is already a student with the same unique ID number.");
                }
            }

            studentsInCourse.Add(student);
            Console.WriteLine("Student {0} added.", student.Name);
        }
Beispiel #5
0
 public void StudentUniqueNumber_ThrowException_9999()
 {
     Student student2 = new Student("Ivan", 9999);
 }
Beispiel #6
0
 public void StudentUniqueNumber_ThrowException_100000()
 {
     Student student2 = new Student("Ivan", 100000);
 }
Beispiel #7
0
 public void StudentUniqueNumber_99999()
 {
     Student student = new Student("Ivan", 99999);
 }
Beispiel #8
0
 public void StudentUniqueNumber_10000()
 {
     Student student = new Student("Ivan", 10000);
 }
Beispiel #9
0
 public void StudentName_ThrowException()
 {
     Student student = new Student("", 10000);
 }