예제 #1
0
파일: CourseTest.cs 프로젝트: vassil/CSharp
        public void CourseList_ThrowException_StudentAlreadyExists()
        {
            Course course = new Course("Math");

            int uniqueID = 11111;

            Student student = new Student("Ivan", uniqueID);
            Student student2 = new Student("Georgi", uniqueID);

            course.AddStudent(student);
            course.AddStudent(student2);
        }
예제 #2
0
파일: CourseTest.cs 프로젝트: vassil/CSharp
        public void CourseList_ThrowException_MoreThan30Students()
        {
            Course course = new Course("Math");

            Random uniqueID = new Random();

            for (int i = 0; i < 50; i++)
            {
                Student student = new Student("Ivan", uniqueID.Next(10000, 99999));
                course.AddStudent(student);
            }
        }
예제 #3
0
파일: School.cs 프로젝트: vassil/CSharp
 public void RemoveCourse(Course course)
 {
     for (int i = 0; i < CoursesInSchool.Count; i++)
     {
         if (CoursesInSchool[i].CourseName == course.CourseName)
         {
             coursesInSchool.Remove(course);
             Console.WriteLine("Course {0} removed.", course.CourseName);
             return;
         }
     }
     Console.WriteLine("Invalid remove operation. Course not found.");
 }
예제 #4
0
파일: School.cs 프로젝트: vassil/CSharp
        public void AddCourse(Course course)
        {
            for (int i = 0; i < CoursesInSchool.Count; i++)
            {
                if (CoursesInSchool[i].CourseName == course.CourseName)
                {
                    throw new InvalidOperationException("There is already a course with the same name.");
                }
            }

            coursesInSchool.Add(course);
            Console.WriteLine("Course {0} added.", course.CourseName);
        }
예제 #5
0
파일: CourseTest.cs 프로젝트: vassil/CSharp
 public void CourseName_ThrowException()
 {
     Course course = new Course("");
 }