< Summary

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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\Transformation\TitlesPropertyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Properties;
 5using ValidateLib.UtilityClasses;
 6
 7namespace ValidateLib.Metadata.PropertyParsers.Transformation
 8{
 9    internal class TitlesPropertyParser : PropertyParserBase<TransformationDescriptor>, IPropertyParser<TransformationDe
 10    {
 111        public TitlesPropertyParser(List<Warning> warnings, TransformationDescriptor descriptor) : base(warnings, descri
 12        {
 113        }
 14
 15        public void ParseProperty(JProperty property)
 16        {
 117            if (property.Value.Type != JTokenType.Object)
 18            {
 019                Warnings.Add(WarningFactory.GetObjectStringNormalizationProblemWarning(property.Value.ToString(), proper
 20            }
 21            else
 22            {
 123                var objectValue = (JObject)property.Value;
 124                var titlesMap = new Dictionary<string, string[]>();
 125                foreach (var jproperty in objectValue.Properties())
 26                {
 127                    if (jproperty.Value.Type != JTokenType.Array)
 28                    {
 029                        Warnings.Add(WarningFactory.GetNaturalLanguageWrongValue(jproperty.Value, jproperty.Name));
 030                        return;
 31                    }
 132                    if (!LanguageUtilityClass.IsCorrectLanguageCode(jproperty.Name))
 33                    {
 034                        Warnings.Add(WarningFactory.GetNaturalLanguageWrongValue(jproperty.Value, jproperty.Name));
 035                        return;
 36                    }
 137                    titlesMap[jproperty.Name] = ((JArray)jproperty.Value).ToObject<string[]>()!;
 38
 39                }
 140                Descriptor.titles = new NaturalLanguageProperty(titlesMap);
 41            }
 142        }
 43    }
 44}