public void TestSchoolAddingCourseWithSameNameToThrow()
 {
     School school = new School("OMG");
     Course js = new Course("JS-OOP");
     school.AddCourse(js);
     school.AddCourse(js);
 }
 public void TestCourseAddingNewStudentToShouldProperlyUpdateList()
 {
     Course course = new Course("financial");
     course.AddStudent(new Student("ivan1", 10001));
     course.AddStudent(new Student("ivan2", 10002));
     Assert.AreEqual(2, course.Students.Count, "List of students is icorrect");
 }
 public void TestCourseAddingStudentWithSameNameToThrow()
 {
     Course course = new Course("JS");
     Student asen = new Student("asen", 10000);
     course.AddStudent(asen);
     course.AddStudent(asen);
 }
Ejemplo n.º 4
0
        private static IDictionary<Course, List<Student>> ReadInputFile(string inputFile)
        {
            StreamReader reader = new StreamReader("../../" + inputFile);
            IDictionary<Course, List<Student>> courses = new SortedDictionary<Course, List<Student>>();

            using (reader)
            {
                string line = reader.ReadLine();

                while (line != null)
                {
                    string[] lineElements = line.Split('|').Select(str => str.Trim()).ToArray();
                    Course course = new Course(lineElements[2]);
                    Student st = new Student(lineElements[0], lineElements[1]);

                    if (courses.ContainsKey(course))
                    {
                        courses[course].Add(st);
                    }
                    else
                    {
                        courses.Add(course, new List<Student> { st });
                    }

                    line = reader.ReadLine();
                }

                return courses;
            }
        }
Ejemplo n.º 5
0
 public void AddCourseToSchool(Course course)
 {
     if (!this.courses.Contains(course))
     {
         this.courses.Add(course);
     }
 }
Ejemplo n.º 6
0
 public void CourseShouldThrowExceptionWhenExistingStudentIsAdded()
 {
     var course = new Course("High Quality Code");
     var student = new Student("Daniel Popov", 10000);
     course.AddStudent(student);
     course.AddStudent(student);
 }
Ejemplo n.º 7
0
 public void CourseShoudRemoveStudentCorrectly()
 {
     var course = new Course("High Quality Code");
     var student = new Student("Daniel Popov", 10000);
     course.AddStudent(student);
     course.RemoveStudent(student);
     Assert.AreEqual(0, course.Students.Count);
 }
 public void TestCourseAddingMoreThan30StudentToThrow()
 {
     Course course = new Course("HQC");
     for (int i = 0; i <= 30; i++)
     {
         course.AddStudent(new Student("asen", 10000 + i));
     }
 }
Ejemplo n.º 9
0
 public void SchoolShouldRemoveCourseCorrectly()
 {
     var school = new School("Telerik Academy");
     var course = new Course("High Quality Code");
     school.AddCourse(course);
     school.RemoveCourse(course);
     Assert.AreEqual(0, school.Courses.Count);
 }
Ejemplo n.º 10
0
 public void CourseShouldThrowExceptionWhenMoreThanPossibleStudentsAdded()
 {
     var course = new Course("High Quality Code");
     for (int i = 0; i < 40; i++)
     {
         course.AddStudent(new Student(i.ToString(), 10000 + i));
     }
 }
Ejemplo n.º 11
0
        public void CourseShouldAddStudentCorrectly()
        {
            var course = new Course("High Quality Code");
            var student = new Student("Daniel Popov", 10000);
            course.AddStudent(student);

            Assert.AreSame(student, course.Students.First());
        }
Ejemplo n.º 12
0
        public void AttendCourse(Course course)
        {
            if (course == null)
            {
                throw new ArgumentNullException("course", "Course cannot be null.");
            }

            course.AddStudent(this);
        }
 public void AddCourseShouldAddTheCourse()
 {
     List<Course> courses = new List<Course>();
     List<Student> students = new List<Student>();
     School IodaSchool = new School(courses);
     string name = "Math";
     Course newCourse = new Course(students, name);
     IodaSchool.AddCourse(newCourse);
 }
Ejemplo n.º 14
0
        public void JoinCourse(Course course)
        {
            if (course == null)
            {
                throw new ArgumentNullException("Course cannot be null");
            }

            course.AddStudent(this);
        }
Ejemplo n.º 15
0
        public void LeaveCourse(Course course)
        {
            if (course == null)
            {
                throw new ArgumentNullException("course", "Course cannot be null.");
            }

            course.RemoveStudent(this);
        }
 public void AddStudentsShouldAddTheStudent()
 {
     string name = "Petur Petrov";
     int uniqueNumber = 10002;
     Student student = new Student(name, uniqueNumber);
     List<Student> students = new List<Student>();
     Course newCourse = new Course(students,"Math");
     newCourse.AddStudent(student);
 }
 public void RemoveCourseShouldRemoveCourseThatAlreadyExist()
 {
     string name = "English";
     List<Student> students = new List<Student>();
     Course newCourse = new Course(students,name);
     List<Course> courses = new List<Course>();
     School IodaSchool = new School(courses);
     IodaSchool.AddCourse(newCourse);
     IodaSchool.RemoveCourse(newCourse);
 }
Ejemplo n.º 18
0
        public void TestOvreloadCourse()
        {
            Course normalCourse = new Course("C# OOP");
            string[] letters = new string[] { "s", "a", "e", "ela", "ina", "ka", "ona", };

            for (int i = 0; i < 60; i++)
            {
                normalCourse.AddStudent(new Student("Ivan" + letters[i % letters.Length], 10101 + i));
            }
        }
 public void RemoveCourseShouldThrowErrorIfCourseDoesNotExist()
 {
     string name = "English";
     List<Student> students = new List<Student>();
     Course newCourse = new Course(students, name);
     Course newCourse2 = new Course(students, name + 2);
     List<Course> courses = new List<Course>();
     School IodaSchool = new School(courses);
     IodaSchool.AddCourse(newCourse);
     IodaSchool.RemoveCourse(newCourse2);
 }
 public void AddCourse(Course course)
 {
     if (this.Courses.Count + 1 <= MaxCoursesCount)
     {
         this.Courses.Add(course);
     }
     else
     {
         throw new ArgumentOutOfRangeException("The school is full with courses! Must have maximum 29 courses!");
     }
 }
 public void RemoveStudentsShouldThrowErrorIfStudentDoesNotExist()
 {
     string name = "Petur Petrov";
     int uniqueNumber = 10002;
     Student student2 = new Student("Goshko", uniqueNumber + 1);
     Student student = new Student(name, uniqueNumber);
     List<Student> students = new List<Student>();
     Course newCourse = new Course(students, "Math");
     newCourse.AddStudent(student);
     newCourse.RemoveStudents(student2);
 }
 public void AddStudentsShouldThrowErrorIfStudentsAreMoreThanMaxStudents()
 {
     List<Student> students = new List<Student>();
     Course newCourse = new Course(students,"English");
     for (int i = 0; i <35 ; i++)
     {
         Student student = new Student("Petur Iordanov", (10001+i));
         newCourse.AddStudent(student);  
     }
   
 }
        private static void AddInfo(string courseName, string firstName, string lastName)
        {
            var course = new Course(courseName);
            var student = new Student(firstName, lastName);

            if (!Result.ContainsKey(course))
            {
                Result[course] = new OrderedBag<Student>();
            }

            Result[course].Add(student);
        }
Ejemplo n.º 24
0
        public void TestAddingStudents()
        {
            Course normalCourse = new Course("C# OOP");
            string[] letters = new string[] { "s", "a", "e", "ela", "ina", "ka", "ona", };

            for (int i = 0; i < 30; i++)
            {
                normalCourse.AddStudent(new Student("Ivan" + letters[i % letters.Length], 10101 + i));
            }

            Assert.AreEqual(30, normalCourse.Participants.Count);
        }
 public void AddCoursesShouldThrowErrorIfCoursesAreMoreThanMaxCourses()
 {
     List<Course> courses = new List<Course>();
     School IodaSchool = new School(courses);
     List<Student> students = new List<Student>();
     
     for (int i = 0; i < 35; i++)
     {
         Course newCourse = new Course(students, ("English"+i));
         IodaSchool.AddCourse(newCourse);
     }
 }
Ejemplo n.º 26
0
        public void TestAddOneCourseManyTimes()
        {
            Student nerd = new Student("Pavel Kolev", 11113);
            Course javaScript = new Course("JavaScript");

            nerd.JointInCourse(javaScript);
            nerd.JointInCourse(javaScript);
            nerd.JointInCourse(javaScript);
            nerd.JointInCourse(javaScript);
            nerd.JointInCourse(javaScript);

            Assert.AreEqual(1, nerd.Courses.Count);
        }
Ejemplo n.º 27
0
        public void AddCourse(Course course)
        {
            if (this.courses.Contains(course))
            {
                throw new ArgumentException("Course already exist");
            }

            if (course == null)
            {
                throw new ArgumentNullException("Course cannot be null");
            }

            this.courses.Add(course);
        }
Ejemplo n.º 28
0
        public void AddCourse(Course course)
        {
            if (course == null)
            {
                throw new ArgumentNullException("Course cannot be null");
            }

            if (this.courses.Contains(course))
            {
                throw new InvalidOperationException("The course has already been added");
            }

            this.courses.Add(course);
        }
Ejemplo n.º 29
0
        public void TestCheckCourses()
        {
            Student nerd = new Student("Pavel Kolev", 11111);
            Student nobbie = new Student("Goran Bognanov", 15151);
            Course cSharp = new Course("C#");
            Course cPlusPlus = new Course("C++");
            Course java = new Course("Java");

            nerd.JointInCourse(cSharp);
            nerd.JointInCourse(cPlusPlus);
            nerd.JointInCourse(java);

            Assert.AreEqual(3, nerd.Courses.Count);
            Assert.AreEqual(0, nobbie.Courses.Count);
        }
        public void RemoveCourse(Course course)
        {
            for (int i = 0; i < this.Courses.Count; i++)
            {
                if (this.Courses[i].Name == course.Name)
                {
                    this.Courses.RemoveAt(i);
                    this.courseIsNotFound = false;
                    break;
                }
            }

            if (this.courseIsNotFound)
            {
                throw new ArgumentException("The course is not found!");
            }
        }