public void GetSchoolByID(int schoolId)
        {
            SchoolDetailsDto school = _schoolController.Get(schoolId);
            var mockSchoolsName     = SchoolAutoMapper.Mapper().Map <SchoolDetailsDto>(_schoolDetails.Result.Where(s => s.SchoolId == schoolId).ToList().First()).SchoolName;

            Assert.AreEqual(school.SchoolName, mockSchoolsName);
        }
        public void GetAllSchoolTest()
        {
            List <SchoolDetailsDto> schools      = _schoolController.Get().Result.ToList();
            List <SchoolDetailsDto> schoolDetail = SchoolAutoMapper.Mapper().Map <List <SchoolDetailsDto> >(_schoolDetails.Result.ToList());

            Assert.IsTrue(schools.GetType().Equals(schoolDetail.GetType()));
        }
        public void PostSchool_ReturnsHttpOkResult()
        {
            School          school       = _schoolDetails.Result.Where(s => s.SchoolId == 1).First();
            CreateSchoolDto detailSchool = SchoolAutoMapper.Mapper().Map <CreateSchoolDto>(school);

            detailSchool.SchoolName = "Test Modified";
            var result = _schoolController.Post(detailSchool);

            Assert.IsInstanceOf <OkObjectResult>(result);
        }
        public void PutSchoolByID_ReturnsHttpBadResult(int id)
        {
            School          school       = _schoolDetails.Result.Where(s => s.SchoolId == 1).First();
            UpdateSchoolDto detailSchool = SchoolAutoMapper.Mapper().Map <UpdateSchoolDto>(school);

            detailSchool.SchoolName = "Test Modified";
            var result = _schoolController.Put(id, detailSchool);

            Assert.IsInstanceOf <BadRequestObjectResult>(result);
        }
        public void SetUp()
        {
            _schoolDetails    = SetUpSchoolDetails();
            _schoolRepository = SetSchoolRepository();
            _redisCache       = new Mock <IDistributedCache>();

            //we can't set property to mock object directly. To achive that implemented below code
            var unitOfData = new Mock <IUnitOfWork>();

            unitOfData.SetupGet(u => u.Repository).Returns(_schoolRepository);
            _unitOfWork = unitOfData.Object;

            _unitOfWork.Repository = _schoolRepository;

            _schoolService = new SchoolService(_unitOfWork, _redisCache.Object);

            _schoolController = new SchoolController(_schoolService, SchoolAutoMapper.Mapper());
        }