< Summary

Information
Class: ValidateLib.Metadata.Properties.ObjectProperty<T>
Assembly: validatelib.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Properties\ObjectProperty.cs
Line coverage
84%
Covered lines: 16
Uncovered lines: 3
Coverable lines: 19
Total lines: 44
Line coverage: 84.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
ObjectProperty(...)20
ObjectProperty(...)02
Normalize(...)211

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\ValidateLib\Metadata\Properties\ObjectProperty.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.IRINormalization;
 4using ValidateLib.Metadata.Descriptors;
 5using ValidateLib.Metadata.Descriptors.Interfaces;
 6using ValidateLib.UtilityClasses;
 7
 8namespace ValidateLib.Metadata.Properties
 9{
 10    public class ObjectProperty<T> : Property<T> where T : class, INormalize
 11    {
 12        string? _objectURL;
 113        public ObjectProperty(T value) : base(value) { }
 014        public ObjectProperty(string url) : base(null)
 15        {
 016            _objectURL = url;
 017        }
 18
 19        public static List<Warning> Normalize(JToken token, Context context, JProperty? property = null)
 20        {
 121            List<Warning> errors = new List<Warning>();
 122            if (token.Type == JTokenType.String)
 23            {
 124                string stringValueOfObjectProperty = token.ToString();
 125                var resolvedLink = IRINormalizator.TurnUrlIntoAbsoluteWithBase(context._base!._value!, stringValueOfObje
 126                JToken? descriptorObjectToken = ObjectPropertyUtilityClass.GetDescriptor(resolvedLink);
 127                if (descriptorObjectToken is null) return errors;
 128                Context? localContext = Context.GetContextFromJToken(descriptorObjectToken, errors, resolvedLink);
 129                if (localContext != null) context = localContext;
 130                ObjectPropertyUtilityClass.RemoveLocalContext((JObject)descriptorObjectToken);
 131                ObjectPropertyUtilityClass.AddId((JObject)descriptorObjectToken, resolvedLink);
 32
 133                token.Replace(descriptorObjectToken);
 134                Normalize(descriptorObjectToken, context, property);
 35
 36            }
 137            else if (token.Type == JTokenType.Object)
 38            {
 139                T.Normalize(token, context, property);
 40            }
 141            return errors;
 42        }
 43    }
 44}