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