public static void Try1() { var repository = new AnotherProductsRepository(); var products = repository.GetAll(); int offset = 0, limit = 10; var subset = OffsetLimitEnumerable.Create(products, offset, limit); var all = PagedEnumerable.Create(products, 2, 10); var all2 = all.CastMetadataEnumerable(p => new ProductWrapper(p)); var dto = all2.ToMetadataObject(); }
public void Given_builder_which_is_null_When_a_PagedEnumerable_is_created_Then_an_ArgumentNullException_should_be_thrown() { // Given. PagedEnumerableBuilder <object> builder = null; // When. Action testCode = () => PagedEnumerable <object> .Create(builder); // Then. testCode.Should() .Throw <ArgumentNullException>() .WithMessage("*cannot be null*builder*"); }
/// <summary> /// Get user's projects. /// </summary> /// <param name="userId">User id the projects related to.</param> /// <param name="page">Page number.</param> /// <param name="pageSize">Page size, default is 10.</param> /// <returns>Projects paged enumerable.</returns> public PagedEnumerable <ProjectDto> GetByUser(string userId, int page, int pageSize = 10) { var query = uow.ProjectRepository.Find(p => p.User.Id == userId).Select(p => new ProjectDto(p)); return(PagedEnumerable.Create(query, page, pageSize)); }