public void AddStudent(Student newStudent) { bool studentExists = this.CheckIfStudentExists(newStudent); if (studentExists) { throw new ArgumentException("The student is already enrolled for this course."); } if (this.Students.Count <= MaxSutentsInCourse) { this.Students.Add(newStudent); } else { throw new ArgumentOutOfRangeException("Class is full!"); } }
public void AddStudentTwiseTest() { Course course = new Course("Math"); Student student = new Student("Gosho", "Ivanov", 12345); course.AddStudent(student); course.AddStudent(student); }