Beispiel #1
0
        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);
        }
Beispiel #2
0
 public void Constructor_WhenNameIsNull_ShoudThrowException()
 {
     Student student = new Student(null, 10030);
 }
Beispiel #3
0
 public void Constructor_WhenNameIsEmpty_ShouldThrowException()
 {
     Student student = new Student("", 10001);
 }
Beispiel #4
0
 public void Constructor_WhenIdIsSmallerThan10000_ShouldThrowException()
 {
     Student student = new Student("James", 9999);
 }
Beispiel #5
0
 public void Constructor_WhenIdIsBiggerThan99999_ShouldThrowException()
 {
     Student student = new Student("James", 100000);
 }
Beispiel #6
0
 public void Constructor_SetsNameToPeter()
 {
     Student student = new Student("Peter", 10001);
     Assert.AreEqual(student.Name, "Peter");
 }
Beispiel #7
0
 public void Constructor_SetsIdTo10001()
 {
     Student student = new Student("Peter", 10001);
     Assert.AreEqual(student.Id, 10001);
 }