public StudentControllerTests()
 {
     studentRepository = new EfRepository<Student>(context);
     markRepository = new EfRepository<Mark>(context);
     schoolRepository = new EfRepository<School>(context);
     controller = new StudentsController(studentRepository, schoolRepository, markRepository);
 }
        public void Add_WhenNameIsValid_ShouldAddTheCategory()
        {
            bool isItemAdded = false;
            var repository = Mock.Create<IRepository<Student>>();

            var studentModel = new Student()
            {
                FirstName = "NEW TEST NAME"
            };
            var studentEntity = new Student()
            {
                StudentId = 1,
                FirstName = studentModel.FirstName
            };
            Mock.Arrange(() => repository.Add(Arg.IsAny<Student>()))
                .DoInstead(() => isItemAdded = true)
                .Returns(studentEntity);

            var controller = new StudentsController(repository);
            SetupController(controller);

            controller.PostStudent(studentModel);

            Assert.IsTrue(isItemAdded);
        }
        public void GetAllCategories_WhenASingleCategoryInRepository_ShouldReturnSingleCategory()
        {
            var repository = new FakeRepository<Student>();

            var studentToAdd = new Student()
            {
                FirstName = "Test category"
            };
            repository.Add(studentToAdd);

            var controller = new StudentsController(repository);

            var categoriesModels = controller.GetStudents();
            Assert.IsTrue(categoriesModels.Count() == 1);
            Assert.AreEqual(studentToAdd.FirstName, categoriesModels.First().FirstName);
        }
        public void GetAll_WhenASingleCategoryInRepository_ShouldReturnSingleCategory()
        {
            var repository = Mock.Create<IRepository<Student>>();
            var studentToAdd = new Student()
            {
                FirstName = "Test category"
            };
            IList<Student> categoryEntities = new List<Student>();
            categoryEntities.Add(studentToAdd);
            Mock.Arrange(() => repository.All()).Returns(() => categoryEntities.AsQueryable());

            var controller = new StudentsController(repository);

            var categoryModels = controller.GetStudents();
            Assert.IsTrue(categoryModels.Count() == 1);
            Assert.AreEqual(studentToAdd.FirstName, categoryModels.First().FirstName);
        }