Exemplo n.º 1
0
 public void TestCourseAddStudentTwice()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.AddStudent(student);
     course.AddStudent(student);
 }
Exemplo n.º 2
0
 public void TestCourseAddStudent()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.AddStudent(student);
     Assert.IsTrue(course.Students.Contains(student));
 }
Exemplo n.º 3
0
        public void CourseConstructorStudentsNullTest()
        {
            string courseName = "C#";
            ICollection<Student> courseStudents = null;

            var course = new Course(courseName, courseStudents);
        }
Exemplo n.º 4
0
        public void CourseGetterNameTest()
        {
            var courseName = "HQC";

            var course = new Course(courseName);

            Assert.AreEqual(courseName, course.Name);
        }
Exemplo n.º 5
0
 public void AddCourse(Course course)
 {
     if (this.IsCourseExist(course))
     {
         throw new ArgumentException("The course has already been added.");
     }
     this.Courses.Add(course);
 }
Exemplo n.º 6
0
 public void TestCourseAddMoreThanMaximumStudents()
 {
     var course = new Course();
     for (int i = 0; i <= 30; i++)
     {
         var student = new Student(i.ToString(), 10000 + i);
         course.AddStudent(student);
     }
 }
Exemplo n.º 7
0
        public void AddCourseTest()
        {
            var course = new Course("JS Fundamentals");

            this.courses.Add(course);

            this.school.AddCourse(course);

            var areEqualResult = this.AreCoursesCollectionsEqual(this.courses, this.school.Courses);

            Assert.AreEqual(true, areEqualResult);
        }
Exemplo n.º 8
0
        public void TestCourseExceedingMaxNumberOfStudentsWhenJoining()
        {
            Student studentToJoin = new Student("Pesho", 34342);

            IList<Student> students = new List<Student>();
            Course course = new Course(students);

            int startingNumber = 10000;
            for (int i = 0; i < Course.MaxStudentCapacity + 1; i++)
            {
                course.Join(new Student("Pesho", startingNumber + i));
            }
        }
Exemplo n.º 9
0
        public void CourseConstructorStudentsMaxCountTest()
        {
            string courseName = "C#";
            ICollection<Student> courseStudents = new List<Student>();

            for (int i = 0; i < Course.MaxStudentsCount + 1; i++)
            {
                string studentName = "test student " + i;
                int studentId = Student.MinIdValue + i;
                courseStudents.Add(new Student(studentName, studentId));
            }

            var course = new Course(courseName, courseStudents);
        }
Exemplo n.º 10
0
        public void TestCourseStudentCount()
        {
            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042)
            };

            Course course = new Course(students);

            Assert.AreEqual(4, course.Students.Count, "Expected to count 4 students.");
        }
Exemplo n.º 11
0
        public void TestCourseAddingMoreThanOneStudentWithSameNumber()
        {
            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042)
            };

            Course course = new Course(students);

            course.Join(new Student("John", 20003));
        }
Exemplo n.º 12
0
        public void InitializeStudent()
        {
            this.students = new List<Student>();

            for (int i = 1; i <= 6; i++)
            {
                string studentName = "test student " + i;
                int studentId = Student.MinIdValue + i;
                this.students.Add(new Student(studentName, studentId));
            }


            this.course = new Course(this.courseName, students);
        }
Exemplo n.º 13
0
        public void TestSchoolCourseCount()
        {
            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042)
            };

            Course course = new Course(students);
            IList<Course> courses = new List<Course>() { course };
            School school = new School(courses);
            Assert.AreEqual(1, school.Courses.Count, "Expected to count 1 school course.");
        }
Exemplo n.º 14
0
        public void TestSchoolRemovingCourse()
        {
            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042)
            };

            Course course = new Course(students);
            School school = new School(new List<Course>());
            school.AddCourse(course);
            school.RemoveCourse(course);
            Assert.AreEqual(0, school.Courses.Count, "Expected to count 1 school course.");
        }
Exemplo n.º 15
0
        public void RemoveCourse(Course course)
        {
            if (!this.IsCourseExist(course))
            {
                throw new ArgumentException("This course hasn't been added.");
            }

            int courseIndex = 0;
            foreach (var curCourse in this.Courses)
            {
                if (curCourse.Name == course.Name)
                {
                    this.Courses.RemoveAt(courseIndex);
                    break;
                }
                courseIndex++;
            }
        }
Exemplo n.º 16
0
        public void TestCourseStudentLeaving()
        {
            Student studentToRemove = new Student("Pesho", 34342);

            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042),
                studentToRemove
            };

            Course course = new Course(students);

            course.Leave(studentToRemove);

            bool studentHasLeft = true;

            for (int i = 0; i < course.Students.Count; i++)
            {
                if (course.Students[i].Name == studentToRemove.Name && course.Students[i].Number == studentToRemove.Number)
                {
                    studentHasLeft = false;
                }
            }

            Assert.AreEqual(4, students.Count, "Expected to count 4 students after removing one from the course.");
            Assert.IsFalse(students.ToString().Contains(studentToRemove.Number.ToString()), "Expected to remove the student from the course but found his unique number.");
            Assert.IsTrue(studentHasLeft, "Expected to not find a student with the same name and number");
        }
Exemplo n.º 17
0
        public void TestCourseStudentsJoining()
        {
            Student studentToJoin = new Student("Pesho", 34342);

            IList<Student> students = new List<Student>()
            {
                new Student("Pesho", 10002),
                new Student("Gosho", 20003),
                new Student("Mariq", 30004),
                new Student("Pettq", 10042),
            };

            Course course = new Course(students);

            course.Join(studentToJoin);

            bool studentHasJoined = false;

            for (int i = 0; i < course.Students.Count; i++)
            {
                if (course.Students[i].Name == studentToJoin.Name && course.Students[i].Number == studentToJoin.Number)
                {
                    studentHasJoined = true;
                }
            }

            Assert.AreEqual(5, students.Count, "Expected to count 5 students after adding one to the course.");
            Assert.IsTrue(course.ToString().Contains(studentToJoin.Number.ToString()), "Expected to find a match for the added students unique number in the course.");
            Assert.IsTrue(studentHasJoined, "Expected to find a student with the same name and number as the added one in the course.");
        }
Exemplo n.º 18
0
 public void RemoveCourse(Course course)
 {
     this.Courses.Remove(course);
 }
Exemplo n.º 19
0
        public void RemoveNonExistingCourseTest()
        {
            var course = new Course("C#");

            this.school.RemoveCourse(course);
        }
Exemplo n.º 20
0
 public void TestCourseRemoveMissingStudent()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.RemoveStudent(student);
 }
Exemplo n.º 21
0
        public void CourseConstructorNameEmptyTest()
        {
            string courseName = string.Empty;

            var course = new Course(courseName);
        }
Exemplo n.º 22
0
        public void CourseConstructorNameNullTest()
        {
            string courseName = null;

            var course = new Course(courseName);
        }
Exemplo n.º 23
0
        public void CourseGetterStudentsTest()
        {
            var courseName = "HQC";
            ICollection<Student> students = new List<Student>();

            for (int i = 0; i < 5; i++)
            {
                string studentName = "test student " + i;
                int studentId = Student.MinIdValue + i;
                students.Add(new Student(studentName, studentId));
            }


            var course = new Course(courseName, students);
            var studentsEqualResult = this.AreStudentCollectionsEqual(students, course.Students);

            Assert.AreEqual(true, studentsEqualResult);
        }
Exemplo n.º 24
0
        public void AddExistingCourseTest()
        {
            var course = new Course("HQC");

            this.school.AddCourse(course);
        }
Exemplo n.º 25
0
 public void TestCourseConstructorCreateStudentsHashSet()
 {
     var course = new Course();
     Assert.AreEqual(0, course.Students.Count);
 }
Exemplo n.º 26
0
 public void AddCourse(Course course)
 {
     this.Courses.Add(course);
 }
Exemplo n.º 27
0
 public void TestCourseAddStudentNull()
 {
     var course = new Course();
     course.AddStudent(null);
 }
Exemplo n.º 28
0
        public void CourseStudentsCountTest()
        {
            var courseName = "HQC";
            var studentsCount = 6;
            ICollection<Student> students = new List<Student>();

            for (int i = 0; i < studentsCount; i++)
            {
                string studentName = "test student " + i;
                int studentId = Student.MinIdValue + i;
                students.Add(new Student(studentName, studentId));
            }


            var course = new Course(courseName, students);
            Assert.AreEqual(studentsCount, course.StudentsCount());
        }
Exemplo n.º 29
0
 private bool IsCourseExist(Course course)
 {
     return this.Courses.Count(x => x.Name == course.Name) > 0;
 }
Exemplo n.º 30
0
 public void TestCourseRemoveStudentNull()
 {
     var course = new Course();
     course.RemoveStudent(null);
 }