Example #1
0
        public List <Student> GetStudents()
        {
            List <Student>        allStudents   = Student.GetAll();
            IEnumerable <Student> foundStudents = allStudents.Where(c => c.MajorId == this.MajorId);

            return(foundStudents.ToList());
        }
Example #2
0
        public void Test_CheckDatabase_ReturnTrueIfEMpty()
        {
            //Arrange, Act
            int actualResult   = Student.GetAll().Count;
            int expectedResult = 0;

            //Assert
            Assert.Equal(expectedResult, actualResult);
        }
        public void GetAll_StartsWithEmptyDB_true()
        {
            //Arrange
            //Act
            List <Student> allStudents = Student.GetAll();

            //Assert
            Assert.Equal(0, allStudents.Count);
        }
        public void Save_SavesToDatabase_true()
        {
            Student        newStudent = new Student("Harry", DateTime.Today);
            List <Student> testList   = new List <Student> {
                newStudent
            };

            newStudent.Save();
            List <Student> result = Student.GetAll();

            Assert.Equal(result, testList);
        }
Example #5
0
        public void Test_GetAll_ReturnsListofStudents()
        {
            //Arrange

            //Act
            firstStudent.Save();
            secondStudent.Save();

            //Assert
            List <Student> actualResult   = Student.GetAll();
            List <Student> expectedResult = new List <Student> {
                firstStudent, secondStudent
            };

            Assert.Equal(expectedResult, actualResult);
        }
        public void Delete_DeletesStudentFromDB_true()
        {
            Student student1 = new Student("Henrietta", DateTime.Today);

            student1.Save();
            Student student2 = new Student("Henry", DateTime.Today);

            student2.Save();
            List <Student> expectedResult = new List <Student> {
                student2
            };

            student1.Delete();
            List <Student> result = Student.GetAll();

            Assert.Equal(expectedResult, result);
        }
Example #7
0
        public void Test_Save_SavesToDatabase()
        {
            //Arrange, Act
            firstStudent.Save();

            //Assert
            List <Student> actualResult   = Student.GetAll();
            List <Student> expectedResult = new List <Student> {
                firstStudent
            };

            foreach (Student student in actualResult)
            {
                Console.WriteLine(student.GetName());
            }

            Assert.Equal(expectedResult, actualResult);
        }