< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.Infrastructure.Specifications.PaginationExtensions
Assembly: ZhEaIsNsAaBn.Infrastructure.Specifications
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Specifications/Extensions/PaginationExtensions.cs
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 28
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Pagination(...)50%44100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Specifications/Extensions/PaginationExtensions.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.Infrastructure.Specifications;
 2
 3/// <summary>Paging for specification builders.</summary>
 4public static class PaginationExtensions
 5{
 6    private const int DefaultPage = 1;
 7
 8    private const int DefaultPageSize = 100;
 9
 10
 11    /// <summary>Adds <c>Skip</c>/<c>Take</c> for the requested page; page 0 or less is 1, page size 0 or less is 100.</
 12    /// <typeparam name="TEntity">The entity type.</typeparam>
 13    /// <param name="specificationBuilder">The specification builder.</param>
 14    /// <param name="filter">The page request.</param>
 15    /// <returns>The builder.</returns>
 16    /// <exception cref="ArgumentNullException">An argument is <see langword="null"/>.</exception>
 17    public static ISpecificationBuilder<TEntity> Pagination< TEntity >( this ISpecificationBuilder<TEntity> specificatio
 18    {
 2819        ArgumentNullException.ThrowIfNull( specificationBuilder );
 2820        ArgumentNullException.ThrowIfNull( filter );
 21
 2822        var page     = filter.Page     <= 0 ? DefaultPage : filter.Page;
 2823        var pageSize = filter.PageSize <= 0 ? DefaultPageSize : filter.PageSize;
 24
 25
 2826        return specificationBuilder.Take( pageSize ).Skip( pageSize * ( page - 1 ) );
 27    }
 28}