< Summary

Information
Class: ValidateLib.Metadata.Descriptors.TableGroupDescriptor
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\TableGroupDescriptor.cs
Line coverage
96%
Covered lines: 26
Uncovered lines: 1
Coverable lines: 27
Total lines: 85
Line coverage: 96.2%
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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Descriptors\TableGroupDescriptor.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Errors;
 3using ValidateLib.ErrorsAndWarnings.Warnings;
 4using ValidateLib.Metadata.Descriptors.Interfaces;
 5using ValidateLib.Metadata.Parsers;
 6using ValidateLib.Metadata.Properties;
 7using ValidateLib.Metadata.PropertyParsers;
 8using ValidateLib.Metadata.PropertyParsers.DescriptorNS;
 9using ValidateLib.Metadata.PropertyParsers.TableGroup;
 10using ValidateLib.UtilityClasses;
 11
 12namespace ValidateLib.Metadata.Descriptors
 13{
 14    public class TableGroupDescriptor : TopLevelObjectDescriptor, IRequiredPropertyValidatable, INormalize, Interfaces.I
 15    {
 16
 117        public ArrayProperty<TableDescriptor>? tables { get; set; }
 118        new public static string getTypeForTypeProperty() => "TableGroup";
 19
 20        new public List<Warning> CheckRequiredPropertiesPresent()
 21        {
 122            List<Warning> errors = ((TopLevelObjectDescriptor)this).CheckRequiredPropertiesPresent();
 123            if (tables == null) ErrorFactory.ThrowRequiredPropertyMissingError("tables", nameof(TableGroupDescriptor));
 124            return errors;
 25        }
 26
 27        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 28        {
 29
 130            List<Warning> errors = new List<Warning>();
 131            if (token.Type != JTokenType.Object) return new List<Warning> { WarningFactory.GetObjectPropertyWrongValueWa
 132            foreach (JProperty jProperty in token)
 33            {
 134                var results = NormalizeProperty(jProperty, context);
 135                MergeTwoList(errors, results);
 36            }
 137            ContextUtilityClass.RemoveContextFromJToken(token);
 138            return errors;
 39        }
 40
 41        new public static List<Warning> NormalizeProperty(JProperty property, Context context)
 42        {
 143            if (CommonProperty.IsCommonProperty(property.Name)) CommonProperty.Normalize(property.Value, context, proper
 144            switch (property.Name)
 45            {
 46                case "tables":
 147                    return ArrayProperty<TableDescriptor>.Normalize<TableDescriptor>(property.Value, context, property);
 48                default:
 149                    return TopLevelObjectDescriptor.NormalizeProperty(property, context);
 50
 51            }
 52        }
 53
 54        new public IPropertyParserBase? GetPropertyParser(JProperty property, List<Warning> warnings)
 55        {
 156            string propertyName = property.Name;
 157            if (CommonProperty.IsCommonProperty(property.Name))
 58            {
 159                ((CommonPropertiesDescriptor)this).GetPropertyParser(property, warnings);
 60            }
 61            switch (propertyName)
 62            {
 63                case "tables":
 164                    return new TablesPropertyParser(warnings, this);
 65                case "@type":
 166                    return new TypePropertyParser<TableGroupDescriptor>(warnings, this);
 67                default:
 168                    return ((TopLevelObjectDescriptor)this).GetPropertyParser(property, warnings);
 69            }
 70        }
 71
 072        public static IParser<TableGroupDescriptor> GetParser(List<Warning> warnings, TableGroupDescriptor? descriptor =
 73
 74        public override void PassInheritedProperties()
 75        {
 176            if (tables is not null)
 77            {
 178                foreach (var table in tables._value!)
 79                {
 180                    table.ProcessPassedInheritedProperties(this);
 81                }
 82            }
 183        }
 84    }
 85}