< Summary

Information
Class: ValidateLib.Metadata.PropertyParsers.Reference.ColumnReferencePropertyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\Reference\ColumnReferencePropertyParser.cs
Line coverage
68%
Covered lines: 11
Uncovered lines: 5
Coverable lines: 16
Total lines: 40
Line coverage: 68.7%
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
ColumnReferencePropertyParser(...)20
ParseProperty(...)3627

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\Reference\ColumnReferencePropertyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Properties;
 5
 6namespace ValidateLib.Metadata.PropertyParsers.Reference
 7{
 8    internal class ColumnReferencePropertyParser : PropertyParserBase<ReferenceDescriptor>, IPropertyParser<ReferenceDes
 9    {
 110        public ColumnReferencePropertyParser(List<Warning> warnings, ReferenceDescriptor descriptor) : base(warnings, de
 11        {
 112        }
 13        public void ParseProperty(JProperty property)
 14        {
 115            if (property.Value.Type == JTokenType.String)
 116                Descriptor.columnReference = new ColumnReferenceProperty(new List<string>() { property.Value.ToString() 
 117            else if (property.Value.Type == JTokenType.Array)
 18            {
 119                List<string> primaryKeys = new List<string>();
 120                foreach (var referencedColumnName in property.Value)
 21                {
 122                    if (referencedColumnName.Type != JTokenType.String)
 23                    {
 024                        Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.V
 025                        return;
 26                    }
 27                    else
 128                        primaryKeys.Add(referencedColumnName.ToString());
 29
 30                }
 131                if (primaryKeys.Count > 0)
 132                    Descriptor.columnReference = new ColumnReferenceProperty(primaryKeys);
 33                else
 034                    Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value
 35            }
 36            else
 037                Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value.Typ
 038        }
 39    }
 40}