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

            var course = new Course(courseName, courseStudents);
        }
Exemple #4
0
        public void CourseGetterNameTest()
        {
            var courseName = "HQC";

            var course = new Course(courseName);

            Assert.AreEqual(courseName, course.Name);
        }
Exemple #5
0
 public void AddCourse(Course course)
 {
     if (this.IsCourseExist(course))
     {
         throw new ArgumentException("The course has already been added.");
     }
     this.Courses.Add(course);
 }
 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);
     }
 }
Exemple #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);
        }
        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));
            }
        }
Exemple #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);
        }
        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.");
        }
        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));
        }
Exemple #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);
        }
        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.");
        }
        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.");
        }
Exemple #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++;
            }
        }
        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");
        }
        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.");
        }
Exemple #18
0
 public void RemoveCourse(Course course)
 {
     this.Courses.Remove(course);
 }
Exemple #19
0
        public void RemoveNonExistingCourseTest()
        {
            var course = new Course("C#");

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

            var course = new Course(courseName);
        }
Exemple #22
0
        public void CourseConstructorNameNullTest()
        {
            string courseName = null;

            var course = new Course(courseName);
        }
Exemple #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);
        }
Exemple #24
0
        public void AddExistingCourseTest()
        {
            var course = new Course("HQC");

            this.school.AddCourse(course);
        }
 public void TestCourseConstructorCreateStudentsHashSet()
 {
     var course = new Course();
     Assert.AreEqual(0, course.Students.Count);
 }
Exemple #26
0
 public void AddCourse(Course course)
 {
     this.Courses.Add(course);
 }
 public void TestCourseAddStudentNull()
 {
     var course = new Course();
     course.AddStudent(null);
 }
Exemple #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());
        }
Exemple #29
0
 private bool IsCourseExist(Course course)
 {
     return this.Courses.Count(x => x.Name == course.Name) > 0;
 }
 public void TestCourseRemoveStudentNull()
 {
     var course = new Course();
     course.RemoveStudent(null);
 }