Esempio n. 1
0
        public void GetAllStudents_WhenMultipleStudentsInRepository_ShouldReturnMultipleStudents()
        {
            var repository = new FakeRepository();

            var studentEntity = new Student()
            {
                FirstName = "John",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity);

            var studentEntity2 = new Student()
            {
                FirstName = "Angel",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity2);

            var studentEntity3 = new Student()
            {
                FirstName = "William",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity3);

            var controller = new StudentsController(repository);
            IEnumerable <StudentModel> studentModels = controller.Get();

            Assert.IsTrue(studentModels.Count() == 3);
            Assert.AreEqual(studentEntity3.FirstName, studentModels.Last().FirstName);
        }
Esempio n. 2
0
        public void GetSingleStudent_WhenStudentNotInRepository_ShouldReturnNull()
        {
            var repository = new FakeRepository();

            var studentEntity = new Student()
            {
                FirstName = "John",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity);

            var studentEntity2 = new Student()
            {
                FirstName = "Angel",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity2);

            var studentEntity3 = new Student()
            {
                FirstName = "William",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity3);

            var          controller   = new StudentsController(repository);
            StudentModel studentModel = controller.Get(4);

            Assert.IsNull(studentModel);
        }
Esempio n. 3
0
        public void GetAllStudents_WhenSingleStudentInRepository_ShouldReturnSingleStudent()
        {
            var repository = new FakeRepository();

            var studentEntity = new Student()
            {
                FirstName = "John",
                LastName  = "Tomson",
                Age       = 15,
                Grade     = 9
            };

            repository.Add(studentEntity);

            var controller = new StudentsController(repository);
            IEnumerable <StudentModel> studentModels = controller.Get();

            Assert.IsTrue(studentModels.Count() == 1);
            Assert.AreEqual(studentEntity.FirstName, studentModels.First().FirstName);
        }