public ActionResult CourseCreate()
        {
            Course newCourse = new Course(Request.Form["course-name"]);

            newCourse.Save();

            return(RedirectToAction("Success", "Home"));
        }
        public void Test_Find_FindsCourseInDatabase()
        {
            //Arrange
            Course testCourse = new Course("Intro To CS");

            testCourse.Save();

            //Act
            Course foundCourse = Course.Find(testCourse.GetId());

            //Assert
            Assert.Equal(testCourse, foundCourse);
        }
        public void Test_Save_AssignsIdToCourseObject()
        {
            //Arrange
            Course testCourse = new Course("Intro To CS");

            testCourse.Save();

            //Act
            Course savedCourse = Course.GetAll()[0];

            int result = savedCourse.GetId();
            int testId = testCourse.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
        public void Test_Save_SavesCourseToDatabase()
        {
            //Arrange
            Course testCourse = new Course("Intro To CS");

            testCourse.Save();

            //Act
            List <Course> result   = Course.GetAll();
            List <Course> testList = new List <Course> {
                testCourse
            };

            //Assert
            Assert.Equal(testList, result);
        }
Beispiel #5
0
        public void Test_AddCourse_AddsCourseToStudent()
        {
            //Arrange
            Student testStudent = new Student("Jasper", "07/24/2017");

            testStudent.Save();

            Course testCourse = new Course("Intro to CS");

            testCourse.Save();

            //Act
            testStudent.AddCourse(testCourse);

            List <Course> result   = testStudent.GetCourses();
            List <Course> testList = new List <Course> {
                testCourse
            };

            //Assert
            Assert.Equal(testList, result);
        }
        public void Test_Delete_DeletesCourseAssociationsFromDatabase()
        {
            //Arrange
            Student testStudent = new Student("Jasper", "07/24/2017");

            testStudent.Save();

            string testName   = "Accounting";
            Course testCourse = new Course(testName);

            testCourse.Save();

            //Act
            testCourse.AddStudent(testStudent);
            testCourse.Delete();

            List <Course> resultStudentCourses = testStudent.GetCourses();
            List <Course> testStudentCourses   = new List <Course> {
            };

            //Assert
            Assert.Equal(testStudentCourses, resultStudentCourses);
        }
Beispiel #7
0
        public void Test_Delete_DeletesStudentAssociationsFromDatabase()
        {
            //Arrange
            Course testCourse = new Course("Intro to CS");

            testCourse.Save();

            string  testName    = "Accounting";
            string  testDate    = "01/03/2017";
            Student testStudent = new Student(testName, testDate);

            testStudent.Save();

            //Act
            testStudent.AddCourse(testCourse);
            testStudent.Delete();

            List <Student> resultCourseStudents = testCourse.GetStudents();
            List <Student> testCourseStudents   = new List <Student> {
            };

            //Assert
            Assert.Equal(testCourseStudents, resultCourseStudents);
        }
        public void Test_GetStudents_RetrievesAllStudentsWithCourse()
        {
            //Arrange
            Course testCourse = new Course("Intro To CS");

            testCourse.Save();
            Student firstStudent = new Student("Matt Caswell", "04/01/2017", testCourse.GetId());

            firstStudent.Save();
            Student secondStudent = new Student("Jasper", "07/24/2017", testCourse.GetId());

            secondStudent.Save();

            //Act
            testCourse.AddStudent(firstStudent);
            testCourse.AddStudent(secondStudent);
            List <Student> testStudentList = new List <Student> {
                firstStudent, secondStudent
            };
            List <Student> resultStudentList = testCourse.GetStudents();

            //Assert
            Assert.Equal(testStudentList, resultStudentList);
        }