public void GetAllStudents_WhenThreeStudentsInRepository_ShouldReturnThreeStudents()
        {
            var repository = new FakeRepository<Student>();

            var studentToAdd1 = new Student()
            {
                FirstName = "Pesho"
            };
            var studentToAdd2 = new Student()
            {
                FirstName = "Pesho"
            };
            var studentToAdd3 = new Student()
            {
                FirstName = "Pesho"
            };
            repository.entities.Add(studentToAdd1);
            repository.entities.Add(studentToAdd2);
            repository.entities.Add(studentToAdd3);

            var controller = new StudentsController(repository);

            var studentModels = controller.GetAll();
            Assert.IsTrue(studentModels.Count() == 3);
        }
        public void GetById_CheckForSingleStudentInRepository()
        {
            var repository = new FakeDbRepository<Student>();

            var stud = new Student()
            {
                FirstName = "First",
                LastName = "Last",
                Age = 100,
                Grade = 1
            };
            repository.entities.Add(stud);

            var studExpected = new StudentModelDetails()
            {
                Name = "First Last",
                Age = 100,
                Grade = 1
            };
            var controller = new StudentsController(repository);

            var studentModel = controller.GetStudent(1);
            Assert.AreEqual(studExpected.Name, studentModel.Name);
            Assert.AreEqual(studExpected.Age, studentModel.Age);
            Assert.AreEqual(studExpected.Grade, studentModel.Grade);
            // Created Student should not have any assigned Mark
            Assert.IsTrue(studentModel.Marks.Count() == 0);
        }
        public void GetAllStudents_WhenNoStudentsInRepository_ShouldReturnNoStudents()
        {
            var repository = new FakeRepository<Student>();
            var controller = new StudentsController(repository);

            var studentModels = controller.GetAll();
            Assert.IsTrue(studentModels.Count() == 0);
        }
        public void GetAll_CheckForSingleStudentInRepository()
        {
            var repository = new FakeDbRepository<Student>();

            var stud = new Student()
            {
                FirstName = "First",
                LastName = "Last",
                Age = 100,
                Grade = 1
            };
            repository.entities.Add(stud);

            var studExpected = new StudentModel()
            {
                Name = "First Last"
            };
            var controller = new StudentsController(repository);

            var studentsModels = controller.GetStudents();
            Assert.IsTrue(studentsModels.Count() == 1);
            Assert.AreEqual(studExpected.Name, studentsModels.First().Name);
        }
        public void GetAll_WhenASingleStudentInRepository_ShouldReturnSingleStudent()
        {
            var repository = Mock.Create<IRepository<Student>>();
            var studentToAdd = new Student()
            {
                FirstName = "Pesho",
                LastName = "Peshev",
                Age = 23
            };
            IList<Student> studentEntities = new List<Student>();
            studentEntities.Add(studentToAdd);
            Mock.Arrange(() => repository.All()).Returns(() => studentEntities.AsQueryable());

            var controller = new StudentsController(repository);

            var studentModels = controller.GetAll();
            Assert.IsTrue(studentModels.Count() == 1);
            Assert.AreEqual(studentToAdd.FirstName, studentModels.First().FirstName);
        }
        public void GetStudentById_ShouldReturnOneStudent()
        {
            var repository = new FakeRepository<Student>();

            var studentToAdd1 = new Student()
            {
                FirstName = "Pesho"
            };
            var studentToAdd2 = new Student()
            {
                FirstName = "Pesho"
            };
            var studentToAdd3 = new Student()
            {
                FirstName = "Pesho"
            };
            repository.entities.Add(studentToAdd1);
            repository.entities.Add(studentToAdd2);
            repository.entities.Add(studentToAdd3);

            var controller = new StudentsController(repository);

            var studentModels = controller.GetSingle(studentToAdd3.StudentId);
            Assert.IsNotNull(studentModels);
            Assert.AreEqual(studentModels.FirstName, studentToAdd3.FirstName);
        }