示例#1
0
        public void GetAssignedCourse_TeacherFound_ReturnsCourses()
        {
            //create the new student
            var newTeacher = new Teacher()
            {
                FirstName = "Mikesh",
                LastName  = "Mistry"
            };

            //add the teacher to the database
            teacherRepository.Add(newTeacher);

            //add some courses
            var courseRepository = new CourseRepository(Context);

            var courseList = new List <Course>();

            // add a list of courses
            courseList.Add(new Course {
                Name = "Introduction to C#", Description = "Introduces students to C# programming"
            });
            courseList.Add(new Course {
                Name = "Introduction to Java", Description = "Introduces students to Java programming"
            });

            //add the course using add range
            courseRepository.AddRange(courseList);

            //use the find method to find a teacher
            var foundTeacher = teacherRepository.Find(teacher => teacher.FirstName == "Mikesh" && teacher.LastName == "Mistry").FirstOrDefault();

            //found the student
            if (foundTeacher != null)
            {
                //enroll the teacher into the two course
                foreach (var course in courseList)
                {
                    courseRepository.AssignTeacherToCourse(foundTeacher.TeacherId, course.CourseId);
                }


                //get the found teacher
                var teacherCourseList = teacherRepository.GetId(foundTeacher.TeacherId);

                if (teacherCourseList != null)
                {
                    //the count of the courseList used to add the courses to the teacher
                    var courseListCount             = courseList.Count();
                    var teacherEnrolledCoursesCount = teacherCourseList.Courses.Count();

                    //insure the counts are the same
                    Assert.AreEqual(courseListCount, teacherEnrolledCoursesCount);

                    //insure that ids are the same
                    Assert.AreEqual(foundTeacher.TeacherId, teacherCourseList.TeacherId);
                }
            }
        }
        public void GetEnrolledCourse_StudentFound_ReturnsCourses()
        {
            //create the new student
            var newStudent = new Student()
            {
                FirstName = "Mikesh",
                LastName  = "Mistry"
            };

            //add the student to the database
            studentRepository.Add(newStudent);

            //add some courses
            var courseRepository = new CourseRepository(Context);

            var courseList = new List <Course>();

            // add a list of courses
            courseList.Add(new Course {
                Name = "Introduction to C#", Description = "Introduces students to C# programming"
            });
            courseList.Add(new Course {
                Name = "Introduction to Java", Description = "Introduces students to Java programming"
            });

            //add the course using add range
            courseRepository.AddRange(courseList);

            //use the find method to find a student
            var foundStudent = studentRepository.Find(student => student.FirstName == "Mikesh" && student.LastName == "Mistry").FirstOrDefault();

            //found the student
            if (foundStudent != null)
            {
                //enroll the student into the two course
                foreach (var course in courseList)
                {
                    courseRepository.EnrollStudentIntoCourse(foundStudent.StudentId, course.CourseId);
                }


                //get the found student
                var studentCourseList = studentRepository.GetId(foundStudent.StudentId);

                if (studentCourseList != null)
                {
                    //the count of the courseList used to add the courses to the student
                    var courseListCount             = courseList.Count();
                    var studentEnrolledCoursesCount = studentCourseList.Courses.Count();

                    //insure the counts are the same
                    Assert.AreEqual(courseListCount, studentEnrolledCoursesCount);

                    //insure that ids are the same
                    Assert.AreEqual(foundStudent.StudentId, studentCourseList.StudentId);
                }
            }
        }
示例#3
0
        public static void AddDummyData()
        {
            List <Software> softwares = new List <Software>()
            {
                new Software("Matlab", "m", OsType.WINDOWS, "Matlab doo", @"http://www.matlab.org", 2005, 200, "Software for science"),
                new Software("Eclipse", "e", OsType.ANY, "Oracle", @"http://www.eclipse.com", 2001, 0, "Software for java app development"),
                new Software("PyCharm", "p", OsType.LINUX, "Python", @"http://www.pycharm.com", 2008, 300, "Software for python app development")
            };

            SoftwareRepository.AddRange(softwares);


            List <Classroom> classrooms = new List <Classroom>()
            {
                new Classroom("L1", "L1", "Description 1", 16, true, true, false, OsType.ANY, new List <Software>()
                {
                    softwares[1]
                }),
                new Classroom("L2", "L2", "Description 2", 32, false, true, false, OsType.WINDOWS, new List <Software>()
                {
                    softwares[0]
                }),
                new Classroom("L3", "L3", "Description 3", 16, true, false, false, OsType.LINUX, new List <Software>()
                {
                    softwares[2]
                }),
                new Classroom("L4", "L4", "Description 4", 32, true, true, false, OsType.ANY, new List <Software>()
                {
                    softwares[0], softwares[1], softwares[2]
                }),
                new Classroom("L5", "L5", "Description 5", 64, false, true, false, OsType.ANY, new List <Software>()
                {
                    softwares[0], softwares[1]
                }),
                new Classroom("L6", "L6", "Description 6", 32, true, true, true, OsType.ANY, new List <Software>()
                {
                    softwares[1], softwares[2]
                })
            };

            ClassroomRepository.AddRange(classrooms);

            List <Course> courses = new List <Course>()
            {
                new Course("Racunarstvo i Automatika", "Ra", "05-9-2000", "Smer za obucavanje inzenjera racunarstva"),
                new Course("Softversko inzenjerstvo i informacione tehnologije", "siit", "12-09-2013", "Najbolji softverski smer FTN-a")
            };

            CourseRepository.AddRange(courses);

            List <Subject> subjects = new List <Subject>()
            {
                new Subject("HCI", "HCI", courses[0], "Najbolji predmet na svetu xD", 16, 2, 6, true, false, false, OsType.WINDOWS, new List <Software>()
                {
                    softwares[1]
                }),
                new Subject("Internet softverske arhitekture", "ISA", courses[1], "Spring", 32, 2, 4, false, true, false, OsType.WINDOWS, new List <Software>()
                {
                    softwares[1]
                }),
                new Subject("Android", "Andrd", courses[0], "Android programiranje", 16, 2, 2, true, true, false, OsType.ANY, new List <Software>()
                {
                    softwares[1]
                }),
                new Subject("PIGKUT", "Pigkut", courses[1], "Izrada seminarskog rada i jos svasta nesto", 32, 2, 4, true, false, true, OsType.WINDOWS, new List <Software>()
                {
                    softwares[1]
                })
            };

            SubjectRepository.AddRange(subjects);

            List <Day> days = new List <Day>()
            {
                new Day("PONEDELJAK"),
                new Day("UTORAK"),
                new Day("SREDA"),
                new Day("ČETVRTAK"),
                new Day("PETAK"),
                new Day("SUBOTA")
            };

            DayRepository.AddRange(days);

            context.SaveChanges();
        }
        public void GetGrades_StudentFound_ReturnsGrades()
        {
            //create the new student
            var newStudent = new Student()
            {
                FirstName = "Mikesh",
                LastName  = "Mistry"
            };

            //add the student to the database
            studentRepository.Add(newStudent);

            //add some courses
            var courseRepository = new CourseRepository(Context);

            var courseList = new List <Course>();

            // add a list of courses
            courseList.Add(new Course {
                Name = "Introduction to C#", Description = "Introduces students to C# programming"
            });
            courseList.Add(new Course {
                Name = "Introduction to Java", Description = "Introduces students to Java programming"
            });

            //add the course using add range
            courseRepository.AddRange(courseList);

            //use the find method to find a student
            var foundstudent = studentRepository.Find(student => student.FirstName == "Mikesh" && student.LastName == "Mistry").FirstOrDefault();



            //found the student
            if (foundstudent != null)
            {
                //enroll the student into the two course
                foreach (var course in courseList)
                {
                    courseRepository.EnrollStudentIntoCourse(foundstudent.StudentId, course.CourseId);
                }


                //get the found student
                var studentCourseList = studentRepository.GetId(foundstudent.StudentId);

                if (studentCourseList != null)
                {
                    //check to see if the grade was added
                    var gradeAdded = false;

                    //assign a student a grade
                    var gradeRepository = new GradeRepository(Context);

                    foreach (var course in studentCourseList.Courses)
                    {
                        gradeAdded = gradeRepository.AssignGradeToStudent(studentCourseList.StudentId, course.CourseId, "A+");
                        Assert.IsTrue(gradeAdded);
                    }


                    Assert.AreEqual(2, studentCourseList.Grades.Count());
                }
            }
        }
 public async Task AddRange(List <Course> courses)
 {
     await courseRepository.AddRange(courses);
 }