예제 #1
0
        public void Student_AddCourse_AddCourseToStudent()
        {
            Student newStudent = new Student("David", new DateTime(2015, 05, 12));

            newStudent.Save();

            Course firstCourse = new Course("Computer Science", "CS101");

            firstCourse.Save();
            Course secondCourse = new Course("Computer Science 2", "CS102");

            secondCourse.Save();

            newStudent.AddCourse(firstCourse);
            newStudent.AddCourse(secondCourse);

            List <Course> studentCourses = newStudent.GetCourses();
            List <Course> controlCourses = new List <Course> {
                firstCourse, secondCourse
            };

            Assert.Equal(controlCourses, studentCourses);
        }
예제 #2
0
        public void AddCourse_AddsCourseToStudent_True()
        {
            Course newCourse = new Course("Ryan", "ryan101");

            newCourse.Save();
            Student newStudent = new Student("Ryan", newDateTime);

            newStudent.Save();
            newStudent.AddCourse(newCourse);
            List <Course> expected = new List <Course> {
                newCourse
            };
            List <Course> result = newStudent.GetCourses();

            Assert.Equal(expected, result);
        }
예제 #3
0
        public void Delete_DeletesAssociation_True()
        {
            Student newStudent = new Student("Ryan", newDateTime);

            newStudent.Save();
            Course newCourse = new Course("Ryan", "Ryan101");

            newCourse.Save();
            newStudent.AddCourse(newCourse);
            newStudent.Delete();

            List <Course> result   = newStudent.GetCourses();
            List <Course> expected = new List <Course> {
            };

            Assert.Equal(expected, result);
        }