< Summary

Information
Class: Pozitron.QuerySpecification.WhereValidator
Assembly: Pozitron.QuerySpecification
File(s): /home/runner/work/QuerySpecification/QuerySpecification/src/QuerySpecification/Validators/WhereValidator.cs
Tag: 52_11740816328
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 30
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 Crap Score Cyclomatic complexity Line 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>
 6public sealed class WhereValidator : IValidator
 7{
 8    /// <summary>
 9    /// Gets the singleton instance of the <see cref="WhereValidator"/> class.
 10    /// </summary>
 111    public static WhereValidator Instance = new();
 212    private WhereValidator() { }
 13
 14    /// <inheritdoc/>
 15    public bool IsValid<T>(T entity, Specification<T> specification)
 16    {
 1217        var compiledItems = specification.GetCompiledItems();
 18
 5119        foreach (var item in compiledItems)
 20        {
 1621            if (item.Type == ItemType.Where && item.Reference is Func<T, bool> compiledExpr)
 22            {
 1223                if (compiledExpr(entity) == false)
 524                    return false;
 25            }
 26        }
 27
 728        return true;
 29    }
 30}