Example #1
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));
            }
        }
Example #2
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));
        }
Example #3
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.");
        }