< Summary

Information
Class: ValidateLib.Metadata.PropertyParsers.DIalect.TrimPropertyParser
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\DIalect\TrimPropertyParser.cs
Line coverage
64%
Covered lines: 9
Uncovered lines: 5
Coverable lines: 14
Total lines: 40
Line coverage: 64.2%
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
TrimPropertyParser(...)20
ParseProperty(...)2322

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\PropertyParsers\DIalect\TrimPropertyParser.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 TrimPropertyParser : PropertyParserBase<DialectDescriptor>, IPropertyParser<DialectDescriptor>
 9    {
 110        public TrimPropertyParser(List<Warning> warnings, DialectDescriptor descriptor) : base(warnings, descriptor)
 11        {
 112        }
 13
 14        public void ParseProperty(JProperty property)
 15        {
 116            string[] acceptedValues = new string[] { "true", "false", "start", "end" };
 117            if (property.Value.Type == JTokenType.Boolean)
 18            {
 119                bool boolValue = (bool)property.Value;
 120                Descriptor.trim = new Properties.AtomicProperties.AtomicPropertyString(boolValue ? "true" : "false");
 21            }
 122            else if (property.Value.Type == JTokenType.String)
 23            {
 024                if (acceptedValues.Contains(property.Value.ToString()))
 025                    Descriptor.trim = new Properties.AtomicProperties.AtomicPropertyString(property.Value.ToString());
 26                else
 27                {
 028                    Warnings.Add(WarningFactory.GetInvalidTrimValueWarning(property.ToString()));
 029                    if (Descriptor.trim == null)
 030                        Descriptor.trim = new AtomicPropertyString("true");
 31                }
 32
 33            }
 34            else
 35            {
 136                Warnings.Add(WarningFactory.GetStringPropertyWrongValueWarning(property.Value, property.Name, property.V
 37            }
 138        }
 39    }
 40}