public void RemoveFromEmptyCourse()
 {
     Student ivan = new Student(10000, "Ivan Ivanov");
     Course emptyCourse = new Course("Empty course");
     emptyCourse.RemoveStudent(ivan);
     Assert.Fail();
 }
 public void CourseAlreadyAddedInSchoolTest()
 {
     School school = new School();
     Course sampleCourse = new Course("Javascript");
     school.AddCourse(sampleCourse);
     school.AddCourse(sampleCourse);
 }
 public void RemoveNonexistingCourseTest()
 {
     School school = new School();
     Course registeredCourse = new Course("Javascript");
     Course notRegisteredCourse = new Course("PHP");
     school.AddCourse(registeredCourse);
     school.RemoveCourse(notRegisteredCourse);
 }
 public void AddStudentToCourseTwiceTest()
 {
     Course sampleCourse = new Course("Javascript");
     Student ivan = new Student(10000, "Ivan Ivanov");
     sampleCourse.AddStudent(ivan);
     sampleCourse.AddStudent(ivan);
     Assert.Fail();
 }
 public void AddStudentToFullCourseTest()
 {
     Course sampleCourse = new Course("Javascript");
     for (int i = 0; i < 31; i++)
     {
         sampleCourse.AddStudent(new Student(10000 + i, "Ivan Ivanov"));
     }
     Assert.Fail();
 }
 public void AddSchoolCourseTest()
 {
     School school = new School();
     Course sampleCourse = new Course("Javascript");
     school.AddCourse(sampleCourse);
     var schoolCourses = school.GetCourses();
     Assert.IsTrue(schoolCourses.Length == 1);
     Assert.AreEqual(sampleCourse, schoolCourses[0]);
 }
 public void RemoveStudentThatIsNotEnrolledTest()
 {
     Student ivan = new Student(10000, "Ivan Ivanov");
     Student pesho = new Student(10001, "Pesho Peshov");
     Course sampleCourse = new Course("Javascript");
     sampleCourse.AddStudent(ivan);
     sampleCourse.RemoveStudent(pesho);
     Assert.Fail();
 }
 public void CourseWithOneStudentTest()
 {
     Student ivan = new Student(10000, "Ivan Ivanov");
     Course sampleCourse = new Course("Javascript");
     sampleCourse.AddStudent(ivan);
     Student[] enrolledStudents = sampleCourse.GetStudents();
     Assert.IsTrue(sampleCourse.CourseName == "Javascript");
     Assert.IsTrue(enrolledStudents.Length == 1);
     Assert.IsTrue(enrolledStudents[0] == ivan);
 }
 public void RemoveStudentFromCourseTest()
 {
     Student ivan = new Student(10000, "Ivan Ivanov");
     Course sampleCourse = new Course("Javascript");
     sampleCourse.AddStudent(ivan);
     Student[] enrolledStudents = sampleCourse.GetStudents();
     Assert.IsTrue(enrolledStudents.Length == 1);
     sampleCourse.RemoveStudent(ivan);
     Student[] enrolledStudentsWithoutStudent = sampleCourse.GetStudents();
     Assert.IsTrue(enrolledStudentsWithoutStudent.Length == 0);
 }
 public void RemoveSchoolCourseTest()
 {
     School school = new School();
     Course sampleCourse = new Course("Javascript");
     school.AddCourse(sampleCourse);
     var schoolCourses = school.GetCourses();
     Assert.AreEqual(1, schoolCourses.Length);
     school.RemoveCourse(sampleCourse);
     var schoolCoursesUpdated = school.GetCourses();
     Assert.AreEqual(0, schoolCoursesUpdated.Length);
 }
        public void AddCourse(Course newCourse)
        {
            if (newCourse == null)
            {
                throw new ArgumentNullException("The course to remove cannot be null!");
            }

            if (this.ContainsCourse(newCourse))
            {
                throw new SchoolException("The course has already been added!");
            }

            this.courses.Add(newCourse);
        }
        public void DisplayEnrolledStudents()
        {
            Student ivan = new Student(10000, "Ivan Ivanov");
            Course sampleCourse = new Course("Javascript");
            sampleCourse.AddStudent(ivan);
            string courseString = sampleCourse.ToString();
            
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Course name: Javascript");
            sb.AppendLine("ID: 10000, Name: Ivan Ivanov");
            string expectedString = sb.ToString();

            Assert.AreEqual(expectedString, courseString);
        }
        public void RemoveCourse(Course courseToRemove)
        {
            if (courseToRemove == null)
            {
                throw new ArgumentNullException("The course to remove cannot be null!");
            }

            if (this.courses.Count == 0)
            {
                throw new SchoolException("There are no registered courses!");
            }
            
            if (!this.ContainsCourse(courseToRemove))
            {
                throw new SchoolException("This course has not been registered in the school!");
            }

            this.courses.Remove(courseToRemove);
        }
        private static void CreateSampleData(StudentSystemContext db)
        {
            var student = new Student()
            {
                StudentId = 1,
                Name = "Georgi Ivanov",
                Number = 2000,
                DateOfBirth = new DateTime(1994, 01, 16)
            };

            var course = new Course()
            {
                Name = "HQC",
                Description = string.Empty,
                Materials = "SOLID, Design Patterns"
            };

            var homework = new Homework()
            {
                HomeworkId = 1,
                CourseId = "HQC",
                StudentId = 1,
                Course = course,
                Student = student,
                DateSent = new DateTime(2015, 10, 10)
            };

            student.Courses.Add(course);
            student.Homeworks.Add(homework);
            course.Students.Add(student);
            course.Homeworks.Add(homework);

            db.Courses.Add(course);
            db.Homeworks.Add(homework);
            db.Students.Add(student);
            db.SaveChanges();
        }
 private bool ContainsCourse(Course courseToCheck)
 {
     Debug.Assert(courseToCheck != null, "The course to check cannot be null!");
     return this.courses.Contains(courseToCheck);
 }
Beispiel #16
0
 private bool ContainsCourse(Course courseToCheck)
 {
     Debug.Assert(courseToCheck != null, "The course to check cannot be null!");
     return(this.courses.Contains(courseToCheck));
 }
 public void RemoveFromEmptyCourseListTest()
 {
     School school = new School();
     Course sampleCourse = new Course("Javascript");
     school.RemoveCourse(sampleCourse);
 }