< Summary

Information
Class: Pozitron.QuerySpecification.WhereValidator
Assembly: Pozitron.QuerySpecification
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Validators/WhereValidator.cs
Tag: 67_15587897385
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 31
Line coverage: 100%
Branch coverage
100%
Covered branches: 8
Total branches: 8
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Cyclomatic complexity NPath complexity Sequence coverage
.cctor()100%11100%
.ctor()100%11100%
IsValid(...)100%88100%

File(s)

/home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Validators/WhereValidator.cs

#LineLine coverage
 1namespace Pozitron.QuerySpecification;
 2
 3/// <summary>
 4/// Represents a validator for where expressions.
 5/// </summary>
 6[ValidatorDiscovery(Order = 10)]
 7public sealed class WhereValidator : IValidator
 8{
 9    /// <summary>
 10    /// Gets the singleton instance of the <see cref="WhereValidator"/> class.
 11    /// </summary>
 212    public static WhereValidator Instance = new();
 413    private WhereValidator() { }
 14
 15    /// <inheritdoc/>
 16    public bool IsValid<T>(T entity, Specification<T> specification)
 17    {
 1218        var compiledItems = specification.GetCompiledItems();
 19
 5120        foreach (var item in compiledItems)
 21        {
 1622            if (item.Type == ItemType.Where && item.Reference is Func<T, bool> compiledExpr)
 23            {
 1224                if (compiledExpr(entity) == false)
 525                    return false;
 26            }
 27        }
 28
 729        return true;
 30    }
 31}