< Summary

Information
Class: ValidateLib.Metadata.PropertyParsers.Schema.PrimaryKeyPropertyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\Schema\PrimaryKeyPropertyParser.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
PrimaryKeyPropertyParser(...)20
ParseProperty(...)3627

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\Schema\PrimaryKeyPropertyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Properties;
 5
 6namespace ValidateLib.Metadata.PropertyParsers.Schema
 7{
 8    internal class PrimaryKeyPropertyParser : PropertyParserBase<SchemaDescriptor>, IPropertyParser<SchemaDescriptor>
 9    {
 110        public PrimaryKeyPropertyParser(List<Warning> warnings, SchemaDescriptor descriptor) : base(warnings, descriptor
 11        {
 112        }
 13        public void ParseProperty(JProperty property)
 14        {
 115            if (property.Value.Type == JTokenType.String)
 116                Descriptor.primaryKey = 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.GetColumnReferencePropertyWrongValueWarning(property.Value, property
 025                        return;
 26                    }
 27                    else
 128                        primaryKeys.Add(referencedColumnName.ToString());
 29
 30                }
 131                if (primaryKeys.Count > 0)
 132                    Descriptor.primaryKey = new ColumnReferenceProperty(primaryKeys);
 33                else
 034                    Warnings.Add(WarningFactory.GetColumnReferencePropertyWrongValueWarning(property.Value, property.Nam
 35            }
 36            else
 037                Warnings.Add(WarningFactory.GetColumnReferencePropertyWrongValueWarning(property.Value, property.Name, p
 38
 039        }
 40    }
 41}