public IActionResult Index(CustomTaskFilter filter) { ViewBag.ProjectId = filter?.ProjectId; var list = _service.Get(filter).ToList(); return(View(list)); }
public void GetByFilterTest() { //Arange Mock <IUnitOfWork> unitOfWorkMock = new Mock <IUnitOfWork>(); Mock <IRepository <CustomTask> > repositoryMock = new Mock <IRepository <CustomTask> >(); repositoryMock.Setup(repo => repo.Get(It.IsAny <Expression <Func <CustomTask, bool> > >())).Returns(_customTasks.AsQueryable); unitOfWorkMock.Setup(getRepo => getRepo.GetRepository <CustomTask>()).Returns(repositoryMock.Object); CustomTaskService customTaskService = new CustomTaskService(unitOfWorkMock.Object); CustomTaskFilter customTaskFilter = new CustomTaskFilter(); //Act IEnumerable <CustomTaskDto> customTasksDto = customTaskService.Get(customTaskFilter); //Assert Assert.NotNull(customTasksDto); Assert.NotEmpty(customTasksDto); Assert.Equal(3, customTasksDto.Count()); }