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); }
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); } }
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"); }
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); }
public void StudentUniqueNumber_ThrowException_9999() { Student student2 = new Student("Ivan", 9999); }
public void StudentUniqueNumber_ThrowException_100000() { Student student2 = new Student("Ivan", 100000); }
public void StudentUniqueNumber_99999() { Student student = new Student("Ivan", 99999); }
public void StudentUniqueNumber_10000() { Student student = new Student("Ivan", 10000); }
public void StudentName_ThrowException() { Student student = new Student("", 10000); }