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

Information
Class: ZhEaIsNsAaBn.Infrastructure.Specifications.BaseSpecification<T1, T2>
Assembly: ZhEaIsNsAaBn.Infrastructure.Specifications
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Specifications/Specifications/BaseSpecificationOfTResult.cs
Line coverage
100%
Covered lines: 1
Uncovered lines: 0
Coverable lines: 1
Total lines: 53
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%11100%

File(s)

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

#LineLine coverage
 1namespace ZhEaIsNsAaBn.Infrastructure.Specifications;
 2
 3/// <summary>
 4/// Base for projecting specifications: an Ardalis <see cref="Specification{T, TResult}"/> (call <c>Query.Select( … )</c
 5/// constructor) that can reject its own filter. Set <see cref="IsValid"/> to a failure and the repository returns it wi
 6/// </summary>
 7/// <typeparam name="TEntity">The entity type.</typeparam>
 8/// <typeparam name="TResult">The read model the rows are projected to.</typeparam>
 9public abstract class BaseSpecification< TEntity, TResult > : Specification<TEntity, TResult>
 10    where TEntity : class
 11{
 12    /// <summary>Success, or the reasons the filter is invalid.</summary>
 7613    public LayerResponse IsValid { get; protected set; } = LayerResponse.Success();
 14}
 15
 16/// <summary>A no-tracking projected list query; derive, add criteria and <c>Query.Select( … )</c>.</summary>
 17/// <typeparam name="TEntity">The entity type.</typeparam>
 18/// <typeparam name="TResult">The read model.</typeparam>
 19public abstract class ListSpecification< TEntity, TResult > : BaseSpecification<TEntity, TResult>
 20    where TEntity : class
 21{
 22    /// <summary>Creates the specification.</summary>
 23    /// <param name="filter">The list filter.</param>
 24    protected ListSpecification( IListFilter<TEntity> filter ) => Query.AsNoTracking();
 25}
 26
 27/// <summary>A projected single-row query, no-tracking unless the filter asks for tracking; derive, add criteria and <c>
 28/// <typeparam name="TEntity">The entity type.</typeparam>
 29/// <typeparam name="TResult">The read model.</typeparam>
 30public abstract class SingleSpecification< TEntity, TResult > : BaseSpecification<TEntity, TResult>
 31    where TEntity : class
 32{
 33    /// <summary>Creates the specification.</summary>
 34    /// <param name="filter">The filter.</param>
 35    /// <exception cref="ArgumentNullException"><paramref name="filter"/> is <see langword="null"/>.</exception>
 36    protected SingleSpecification( ISingleFilter<TEntity> filter )
 37    {
 38        ArgumentNullException.ThrowIfNull( filter );
 39
 40        if ( filter.AsNoTracking ) { Query.AsNoTracking(); }
 41    }
 42}
 43
 44/// <summary>A no-tracking projected page query (see <see cref="PaginationExtensions.Pagination{TEntity}"/>); derive, ad
 45/// <typeparam name="TEntity">The entity type.</typeparam>
 46/// <typeparam name="TResult">The read model.</typeparam>
 47public abstract class PaginationSpecification< TEntity, TResult > : BaseSpecification<TEntity, TResult>
 48    where TEntity : class
 49{
 50    /// <summary>Creates the specification.</summary>
 51    /// <param name="filter">The page request.</param>
 52    protected PaginationSpecification( IPaginationFilter<TEntity> filter ) => Query.AsNoTracking().Pagination( filter );
 53}

Methods/Properties

.ctor()