< Summary

Information
Class: Fluorite.Strainer.Services.Metadata.Attributes.AttributeCriteriaChecker
Assembly: Fluorite.Strainer
File(s): /builds/fluorite/strainer/src/Strainer/Services/Metadata/Attributes/AttributeCriteriaChecker.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 44
Line coverage: 100%
Branch coverage
100%
Covered branches: 24
Total branches: 24
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
CheckIfObjectAttributeIsMatching(...)100%1010100%
CheckIfPropertyAttributeIsMatching(...)100%1414100%

File(s)

/builds/fluorite/strainer/src/Strainer/Services/Metadata/Attributes/AttributeCriteriaChecker.cs

#LineLine coverage
 1using Fluorite.Strainer.Attributes;
 2using System.Reflection;
 3
 4namespace Fluorite.Strainer.Services.Metadata.Attributes;
 5
 6public class AttributeCriteriaChecker : IAttributeCriteriaChecker
 7{
 8    public bool CheckIfObjectAttributeIsMatching(
 9        StrainerObjectAttribute? attribute,
 10        PropertyInfo? propertyInfo,
 11        bool isSortableRequired,
 12        bool isFilterableRequired)
 13    {
 14        // An object attribue is matching when all of these conditions are met:
 15        // - StrainerObjectAttribute was found
 16        // - property info was found
 17        // - attribute has sortable flag enabled or sorting is not required
 18        // - attribute has filterable flag enabled or filtering is not required
 1019        return attribute != null
 1020            && propertyInfo != null
 1021            && (!isSortableRequired || attribute.IsSortable)
 1022            && (!isFilterableRequired || attribute.IsFilterable);
 23    }
 24
 25    public bool CheckIfPropertyAttributeIsMatching(
 26        StrainerPropertyAttribute? attribute,
 27        PropertyInfo? propertyInfo,
 28        bool isSortableRequired,
 29        bool isFilterableRequired,
 30        string name)
 31    {
 32        // An property attribue is matching when all of these conditions are met:
 33        // - StrainerPropertyAttribute was found
 34        // - property info was found
 35        // - attribute has sortable flag enabled or sorting is not required
 36        // - attribute has filterable flag enabled or filtering is not required
 37        // - attribute/property name equals provided name
 1638        return attribute is not null
 1639            && propertyInfo != null
 1640            && (!isSortableRequired || attribute.IsSortable)
 1641            && (!isFilterableRequired || attribute.IsFilterable)
 1642            && string.Equals(attribute.DisplayName ?? attribute.Name, name);
 43    }
 44}