< Summary

Information
Class: ValidateLib.Metadata.PropertyParsers.ForeignKey.ColumnReferencePropertyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\ForeignKey\ColumnReferencePropertyParser.cs
Line coverage
68%
Covered lines: 11
Uncovered lines: 5
Coverable lines: 16
Total lines: 41
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\ForeignKey\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.ForeignKey
 7{
 8    internal class ColumnReferencePropertyParser : PropertyParserBase<ForeignKeyDescriptor>, IPropertyParser<ForeignKeyD
 9    {
 110        public ColumnReferencePropertyParser(List<Warning> warnings, ForeignKeyDescriptor descriptor) : base(warnings, d
 11        {
 112        }
 13
 14        public void ParseProperty(JProperty property)
 15        {
 116            if (property.Value.Type == JTokenType.String)
 117                Descriptor.columnReference = new ColumnReferenceProperty(new List<string>() { property.Value.ToString() 
 118            else if (property.Value.Type == JTokenType.Array)
 19            {
 120                List<string> referencingColumns = new List<string>();
 121                foreach (var referencedColumnName in property.Value)
 22                {
 123                    if (referencedColumnName.Type != JTokenType.String)
 24                    {
 025                        Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.V
 026                        return;
 27                    }
 28                    else
 129                        referencingColumns.Add(referencedColumnName.ToString());
 30
 31                }
 132                if (referencingColumns.Count > 0)
 133                    Descriptor.columnReference = new ColumnReferenceProperty(referencingColumns);
 34                else
 035                    Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value
 36            }
 37            else
 038                Warnings.Add(WarningFactory.GetInvalidColumnReferenceValue(property.Value.ToString(), property.Value.Typ
 039        }
 40    }
 41}