< Summary

Information
Class: ValidateLib.Metadata.PropertyParsers.DIalect.LineTerminatorsPropertyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\DIalect\LineTerminatorsPropertyParser.cs
Line coverage
80%
Covered lines: 12
Uncovered lines: 3
Coverable lines: 15
Total lines: 41
Line coverage: 80%
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
LineTerminatorsPropertyParser(...)20
ParseProperty(...)3816

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\DIalect\LineTerminatorsPropertyParser.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.Metadata.Descriptors;
 4using ValidateLib.Metadata.Properties.AtomicProperties;
 5
 6namespace ValidateLib.Metadata.PropertyParsers.DIalect
 7{
 8    internal class LineTerminatorsPropertyParser : PropertyParserBase<DialectDescriptor>, IPropertyParser<DialectDescrip
 9    {
 110        public LineTerminatorsPropertyParser(List<Warning> warnings, DialectDescriptor descriptor) : base(warnings, desc
 11        {
 112        }
 13
 14        public void ParseProperty(JProperty property)
 15        {
 116            List<string> lineTerminators = new List<string>();
 117            List<string> defaultValue = new List<string> { "\\r\\n", "\\n" };
 118            if (property.Value.Type == JTokenType.String)
 019                lineTerminators.Add(property.Value.ToString());
 120            else if (property.Value.Type == JTokenType.Array)
 21            {
 122                foreach (var item in property.Value)
 23                {
 124                    if (item.Type != JTokenType.String)
 25                    {
 026                        Warnings.Add(WarningFactory.GetStringPropertyWrongValueWarning(property.Value, property.Name, pr
 027                        Descriptor.lineTerminators = new AtomicPropertyArray<string>(defaultValue);
 28                    }
 29                    else
 30                    {
 131                        lineTerminators.Add(item.ToString());
 32                    }
 33                }
 134                Descriptor.lineTerminators = new AtomicPropertyArray<string>(lineTerminators);
 35            }
 36            else
 137                Warnings.Add(WarningFactory.GetLineTerminatorsWrongValueWarning(property.Value.ToString(), property.Valu
 38
 139        }
 40    }
 41}