< Summary

Information
Class: ValidateLib.Metadata.Parsers.ForeignKeyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Parsers\ForeignKeyParser.cs
Line coverage
93%
Covered lines: 14
Uncovered lines: 1
Coverable lines: 15
Total lines: 45
Line coverage: 93.3%
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

MethodBlocks covered Blocks not covered
ForeignKeyParser(...)20
ParseJToken(...)356

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Parsers\ForeignKeyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Errors;
 3using ValidateLib.ErrorsAndWarnings.Warnings;
 4using ValidateLib.Metadata.Descriptors;
 5using ValidateLib.Metadata.Descriptors.Interfaces;
 6
 7namespace ValidateLib.Metadata.Parsers
 8{
 9    internal class ForeignKeyParser : DescriptorParserBase<ForeignKeyDescriptor>, IParser<ForeignKeyDescriptor>
 10    {
 111        public ForeignKeyParser(List<Warning> warnings, ForeignKeyDescriptor? descriptor = null) : base(warnings, descri
 12        {
 113        }
 14
 15        new public ForeignKeyDescriptor ParseJToken(JToken jToken, string propertyName)
 16        {
 117            if (jToken.Type != JTokenType.Object)
 18            {
 119                if (jToken.Type == JTokenType.String)
 020                    Warnings.Add(WarningFactory.GetObjectStringNormalizationProblemWarning(jToken.ToString(), propertyNa
 21                else
 122                    Warnings.Add(WarningFactory.GetObjectPropertyWrongValueWarning(jToken, propertyName));
 123                Descriptor.IsInvalid = true;
 124                return Descriptor;
 25            }
 26            else
 27            {
 128                foreach (JProperty property in jToken)
 29                {
 130                    var propertyParser = Descriptor.GetPropertyParser(property, Warnings);
 131                    if (propertyParser == null)
 32                    {
 133                        ErrorFactory.ThrowInvalidPropertyOnFKDescriptorError(property.ToString());
 34                    }
 35                    else
 36                    {
 137                        propertyParser.ParseProperty(property);
 38                    }
 39                }
 140                if (Descriptor is IRequiredPropertyValidatable) ((IRequiredPropertyValidatable)Descriptor).CheckRequired
 141                return Descriptor;
 42            }
 43        }
 44    }
 45}