public async Task VerifyRetrievingFetchesData() { var service = new Mock <IGetByFilterService <TestDto, TestFilter> >(); var paginatedEnumerable = new PaginatedEnumerable <TestDto>(); service.Setup(s => s.GetItems(It.IsAny <TestFilter>())).Returns(async() => paginatedEnumerable); var collection = new ObservableServiceCollection <TestDto, TestFilter, IGetByFilterService <TestDto, TestFilter> >(service.Object); paginatedEnumerable.AddRange(new[] { new TestDto { Id = 1 }, new TestDto { Id = 2 }, new TestDto { Id = 3 } }); collection.Count.ShouldBe(0); await collection.LoadMore(); collection.Count.ShouldBe(3); collection[0].Id.ShouldBe(1); collection[1].Id.ShouldBe(2); collection[2].Id.ShouldBe(3); }
public void GetEnumerator_PageChanges_ReturnCorrectItems(int page, int start, int end) { var paginatedEnumeration = new PaginatedEnumerable <int>(_data13Ints, page, 5); var pe = paginatedEnumeration.ToArray(); Assert.Equal(_data13Ints[start..end], pe);
public async Task <PaginatedEnumerable <TEntity> > ListPaginatedAsync(ISpecification <TEntity> specification = null) { IQueryable <TEntity> query = ApplySpecification(specification); PaginatedEnumerable <TEntity> list = await query.ToPaginatedAsync(specification); return(list); }
public async Task <PaginatedEnumerableDto <StudentDto> > ListAsync( int pageIndex, int pageSize, string sortBy = null, bool?ascending = false, int?id = null, string lastName = null, string firstMidName = null, DateTime?enrollmentStartDate = null, DateTime?enrollmentEndDate = null, List <int> enrollmentsId = null, string mail = null, int?age = null, bool?asNoTracking = null) { try { StudentSpecification specification = new StudentSpecification(pageIndex, pageSize, asNoTracking, sortBy, ascending) { Id = id, LastName = lastName, FirstMidName = firstMidName, EnrollmentStartDate = enrollmentStartDate, EnrollmentEndDate = enrollmentEndDate, EnrollmentsId = enrollmentsId, Mail = mail, Age = age, }; PaginatedEnumerable <Student> students = await _uow.StudentRepository.ListPaginatedAsync(specification); StudentDto sa = _mapper.Map <StudentDto>(students.Items.FirstOrDefault()); IEnumerable <StudentDto> s = _mapper.Map <IEnumerable <StudentDto> >(students.Items); PaginatedEnumerableDto <StudentDto> studentsDto = _mapper.Map <PaginatedEnumerableDto <StudentDto> >(students); return(studentsDto); } catch (AutoMapperMappingException ex) { throw; } catch (Exception ex) { throw; } }