예제 #1
0
        public void ExpectCourseToAddAStudent()
        {
            var course = new Course();
            var billy = new Student("Billy", 10000);
            course.AddStudent(billy);

            Assert.AreSame(billy, course.getStudents[0], "Expects the student inside the course to be the same");
        }
예제 #2
0
        public void ExpectAddingStudentsToSchoolToAddThemCorrectly()
        {
            var school = new School();
            var billy = new Student("Billy", 10000);

            school.AddStudent(billy);
            Assert.AreEqual(school.Students[0], billy, "Expect the add method to add valid students correctly");
        }
예제 #3
0
        public void ExpectRemoveStudentInSchoolToRemoveAnAddedStudent()
        {
            var school = new School();
            var billy = new Student("Billy", 10000);
            school.AddStudent(billy);
            school.RemoveStudent(billy);

            Assert.AreEqual(school.Students.Count, 0, "Expects the students list to be empty");
        }
예제 #4
0
        public void ExpectAddStudentToSchoolToThrowWhenAddingADuplicatedID()
        {
            var school = new School();
            var billy = new Student("Billy", 10000);
            var willy = new Student("Willy", 10000);

            school.AddStudent(billy);
            school.AddStudent(willy);
        }
예제 #5
0
        public void ExpectCourseToRemoveStudent()
        {
            var course = new Course();
            var billy = new Student("Billy", 10000);
            course.AddStudent(billy);
            course.RemoveStudent(course.getStudents[0]);

            Assert.AreEqual(course.getStudents.Count, 0, "Expects the students list to be empty");
        }
예제 #6
0
 public void ExpectAddMethodToThrowWhenAddingMoreThan30Students()
 {
     var course = new Course();
     for (int i = 0; i <= 30; i++)
     {
         var billy = new Student("Billy" + i, 10000 + i);
         course.AddStudent(billy);
     }
 }
예제 #7
0
        public void ExpectAddCourseToAddTheCourse()
        {
            var school = new School();
            var course = new Course();
            var billy = new Student("Billy", 10000);
            course.AddStudent(billy);

            school.AddCourse(course);

            Assert.AreEqual(school.Courses[0], course, "Expected the school to have an added course");
        }
예제 #8
0
        public void ExpectRemoveCourseToRemoveTheCourse()
        {
            var school = new School();
            var course = new Course();
            var billy = new Student("Billy", 10000);
            course.AddStudent(billy);

            school.AddCourse(course);
            school.RemoveCourse(course);

            Assert.AreEqual(school.Courses.Count, 0, "Expected the school to have an empty course list");
        }
예제 #9
0
 public void AddStudent(Student student)
 {
     if (student == null)
     {
         throw new ArgumentNullException("You cannot have a null student added to the course");
     }
     if (this.studentSet.Count == maximumStudentCount)
     {
         throw new ArgumentOutOfRangeException(string.Format("The students in a course cannot be more than {0}", maximumStudentCount));
     }
     studentSet.Add(student);
 }
예제 #10
0
 public void AddStudent(Student student)
 {
     if (student == null)
     {
         throw new ArgumentNullException("You cannot have a student with a null value added to the school!");
     }
     if (this.students.Any(x => x.Id == student.Id))
     {
         throw new ArgumentException("You cannot have students with the same ID in a school");
     }
     this.students.Add(student);
 }
예제 #11
0
 public void RemoveStudent(Student student)
 {
     studentSet.Remove(student);
 }
예제 #12
0
 public void RemoveStudent(Student student)
 {
     this.students.Remove(student);
 }