public void AddStudent(Student student) { if (this.FindStudent(student.Id)) { throw new ArgumentException("The student has already been added to the course."); } if (this.NumberOfStudents == Course.MaximumNumberOfStudents) { throw new ArgumentOutOfRangeException("The maximum number of students in a course is: " + Course.MaximumNumberOfStudents); } this.students.Add(student); }
public void Constructor_WhenNameIsNull_ShoudThrowException() { Student student = new Student(null, 10030); }
public void Constructor_WhenNameIsEmpty_ShouldThrowException() { Student student = new Student("", 10001); }
public void Constructor_WhenIdIsSmallerThan10000_ShouldThrowException() { Student student = new Student("James", 9999); }
public void Constructor_WhenIdIsBiggerThan99999_ShouldThrowException() { Student student = new Student("James", 100000); }
public void Constructor_SetsNameToPeter() { Student student = new Student("Peter", 10001); Assert.AreEqual(student.Name, "Peter"); }
public void Constructor_SetsIdTo10001() { Student student = new Student("Peter", 10001); Assert.AreEqual(student.Id, 10001); }