Exemplo n.º 1
0
        public void AddStudent(Student student)
        {
            if (student == null)
            {
                throw new ArgumentNullException("Student cannot be null");
            }

            if (this.studentsList.Count < 29)
            {
                if (this.studentsList.Contains(student))
                {
                    throw new ApplicationException("The same student cannot be added more than once");
                }
                this.studentsList.Add(student);
                student.AddCourse(this);
                return;
            }

            throw new ApplicationException("Students in a class must be less than 30");
        }
Exemplo n.º 2
0
        public void AddStudent(Student student)
        {
            if (student == null)
            {
                throw new ArgumentNullException("Student cannot be null");
            }

            if (this.studentsList.Count < 29)
            {
                if (this.studentsList.Contains(student))
                {
                    throw new ApplicationException("The same student cannot be added more than once");
                }
                this.studentsList.Add(student);
                student.AddCourse(this);
                return;
            }

            throw new ApplicationException("Students in a class must be less than 30");
        }
Exemplo n.º 3
0
        public void GetCourseStudentInfo()
        {
            Student pesho = new Student("Pepito", 10101);
            pesho.AddCourse(new Course("Pottary"));

            StringBuilder actualResult = new StringBuilder();
            actualResult.AppendLine(pesho.DisplayCourseInfoToConsoleAndReturnValue());

            StringBuilder expectedResult = new StringBuilder();
            expectedResult.AppendLine("Pepito is attending:");
            expectedResult.AppendFormat("Course name: Pottary");
            expectedResult.AppendLine();
            Assert.AreEqual(expectedResult, expectedResult);
        }