Ejemplo n.º 1
0
        public void Test_Save_AssignsIdToObject()
        {
            //Arrange
            Student testStudent = new Student("Jasper", "07/24/2017");

            //Act
            testStudent.Save();
            Student savedStudent = Student.GetAll()[0];


            int result = savedStudent.GetId();
            int testId = testStudent.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Ejemplo n.º 2
0
        public void Test_SaveAssignsIdToObject()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

            //Act
            Student savedStudent = Student.GetAll()[0];

            int result = savedStudent.GetId();
            int testId = testStudent.GetId();

            //Assert
            Assert.Equal(testId, result);
        }
Ejemplo n.º 3
0
        public void Test_Save()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

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

            //Assert
            Assert.Equal(testList, result);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        public void Test_AddClass_AddsClassToStudent()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

            Class testClass = new Class("History");

            testClass.Save();

            //Act
            testStudent.AddClass(testClass);

            List <Class> result   = testStudent.GetClasses();
            List <Class> testList = new List <Class> {
                testClass
            };

            //Assert
            Assert.Equal(testList, result);
        }
Ejemplo n.º 6
0
        public void Test_Delete_DeletesClassAssociationsFromDatabase()
        {
            //Arrange
            Student testStudent = new Student("Steve");

            testStudent.Save();

            string testName  = "History";
            Class  testClass = new Class(testName);

            testClass.Save();

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

            List <Class> resultStudentClasses = testStudent.GetClasses();
            List <Class> testStudentClasses   = new List <Class> {
            };

            //Assert
            Assert.Equal(testStudentClasses, resultStudentClasses);
        }
Ejemplo n.º 7
0
        public void Test_Delete_DeletesStudentAssociationsFromDatabase()
        {
            //Arrange
            Class testClass = new Class("History");

            testClass.Save();

            string  testDescription = "Steve";
            Student testStudent     = new Student(testDescription);

            testStudent.Save();

            //Act
            testStudent.AddClass(testClass);
            testStudent.Delete();

            List <Student> resultClassStudents = testClass.GetStudents();
            List <Student> testClassStudents   = new List <Student> {
            };

            //Assert
            Assert.Equal(testClassStudents, resultClassStudents);
        }
Ejemplo n.º 8
0
        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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        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);
        }