コード例 #1
0
 public void TestCourseAddStudentTwice()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.AddStudent(student);
     course.AddStudent(student);
 }
コード例 #2
0
 public void TestCourseAddStudent()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.AddStudent(student);
     Assert.IsTrue(course.Students.Contains(student));
 }
コード例 #3
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        public void CourseConstructorStudentsNullTest()
        {
            string courseName = "C#";
            ICollection<Student> courseStudents = null;

            var course = new Course(courseName, courseStudents);
        }
コード例 #4
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        public void CourseGetterNameTest()
        {
            var courseName = "HQC";

            var course = new Course(courseName);

            Assert.AreEqual(courseName, course.Name);
        }
コード例 #5
0
ファイル: School.cs プロジェクト: jesusico83/Telerik
 public void AddCourse(Course course)
 {
     if (this.IsCourseExist(course))
     {
         throw new ArgumentException("The course has already been added.");
     }
     this.Courses.Add(course);
 }
コード例 #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);
     }
 }
コード例 #7
0
ファイル: SchoolTest.cs プロジェクト: jesusico83/Telerik
        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);
        }
コード例 #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));
            }
        }
コード例 #9
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        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);
        }
コード例 #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.");
        }
コード例 #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));
        }
コード例 #12
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        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);
        }
コード例 #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.");
        }
コード例 #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.");
        }
コード例 #15
0
ファイル: School.cs プロジェクト: jesusico83/Telerik
        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++;
            }
        }
コード例 #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");
        }
コード例 #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.");
        }
コード例 #18
0
ファイル: School.cs プロジェクト: nader-dab/CSharp-Homeworks
 public void RemoveCourse(Course course)
 {
     this.Courses.Remove(course);
 }
コード例 #19
0
ファイル: SchoolTest.cs プロジェクト: jesusico83/Telerik
        public void RemoveNonExistingCourseTest()
        {
            var course = new Course("C#");

            this.school.RemoveCourse(course);
        }
コード例 #20
0
 public void TestCourseRemoveMissingStudent()
 {
     var course = new Course();
     var student = new Student("Name", 12345);
     course.RemoveStudent(student);
 }
コード例 #21
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        public void CourseConstructorNameEmptyTest()
        {
            string courseName = string.Empty;

            var course = new Course(courseName);
        }
コード例 #22
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        public void CourseConstructorNameNullTest()
        {
            string courseName = null;

            var course = new Course(courseName);
        }
コード例 #23
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        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);
        }
コード例 #24
0
ファイル: SchoolTest.cs プロジェクト: jesusico83/Telerik
        public void AddExistingCourseTest()
        {
            var course = new Course("HQC");

            this.school.AddCourse(course);
        }
コード例 #25
0
 public void TestCourseConstructorCreateStudentsHashSet()
 {
     var course = new Course();
     Assert.AreEqual(0, course.Students.Count);
 }
コード例 #26
0
ファイル: School.cs プロジェクト: nader-dab/CSharp-Homeworks
 public void AddCourse(Course course)
 {
     this.Courses.Add(course);
 }
コード例 #27
0
 public void TestCourseAddStudentNull()
 {
     var course = new Course();
     course.AddStudent(null);
 }
コード例 #28
0
ファイル: CourseTest.cs プロジェクト: jesusico83/Telerik
        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());
        }
コード例 #29
0
ファイル: School.cs プロジェクト: jesusico83/Telerik
 private bool IsCourseExist(Course course)
 {
     return this.Courses.Count(x => x.Name == course.Name) > 0;
 }
コード例 #30
0
 public void TestCourseRemoveStudentNull()
 {
     var course = new Course();
     course.RemoveStudent(null);
 }