public void GetAllTest() { //Arange Mock <IUnitOfWork> unitOfWorkMock = new Mock <IUnitOfWork>(); Mock <IRepository <Rate> > repositoryMock = new Mock <IRepository <Rate> >(); repositoryMock.Setup(repo => repo.Get(It.IsAny <Expression <Func <Rate, bool> > >())).Returns(_rates.AsQueryable); unitOfWorkMock.Setup(getRepo => getRepo.GetRepository <Rate>()).Returns(repositoryMock.Object); RateService _rateService = new RateService(unitOfWorkMock.Object); //Act IEnumerable <RateDTO> _ratesDto = _rateService.GetAll(); //Assert Assert.NotNull(_ratesDto); Assert.NotEmpty(_ratesDto); Assert.Equal(3, _ratesDto.Count()); }
public ActionResult GetAllIndexRate(DataSourceRequest request) { var res = _rateService.GetAll(request); return(Json(res, JsonRequestBehavior.AllowGet)); }