< Summary

Information
Class: NormalizationTests.LinkPropertiesTests
Assembly: normalizationtests.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\NormalizationTests\LinkPropertiesTests.cs
Line coverage
96%
Covered lines: 25
Uncovered lines: 1
Coverable lines: 26
Total lines: 57
Line coverage: 96.1%
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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\NormalizationTests\LinkPropertiesTests.cs

#LineLine coverage
 1using Newtonsoft.Json.Linq;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5using System.Text;
 6using System.Threading.Tasks;
 7using ValidateLib.ErrorsAndWarnings.Warnings;
 8using ValidateLib.Metadata.Descriptors;
 9using ValidateLib.Metadata.Properties;
 10
 11namespace NormalizationTests
 12{
 13    public  class LinkPropertiesTests
 14    {
 15        public readonly string testFilesDirectory;
 116        public LinkPropertiesTests()
 117        {
 118            testFilesDirectory = Path.Combine(GetProjectDirectory(),"TestFiles", "LinkPropertiesTests");
 119        }
 20        static string GetProjectDirectory()
 121        {
 122            string? currentDirectory = Directory.GetCurrentDirectory();
 23
 124            while (!string.IsNullOrEmpty(currentDirectory))
 125            {
 126                string[] projectFiles = Directory.GetFiles(currentDirectory, "*.csproj");
 27
 128                if (projectFiles.Length > 0)
 129                    return currentDirectory;
 130                currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
 131            }
 32
 033            throw new Exception("Could not find project directory.");
 134        }
 35        [Fact]
 36        public void NaturalLanguagePropertyStringToObjectEnLanguageTest()
 137        {
 138            string testFilePath = Path.Combine(testFilesDirectory, "testFile1.json");
 139            string jsonString = File.ReadAllText(testFilePath);
 140            JObject jsonObject = JObject.Parse(jsonString);
 41
 142            List<Warning> warnings = new List<Warning>();
 143            Context context = Context.GetContextFromJToken(jsonObject,warnings, testFilePath);
 44
 45
 146            var property = jsonObject.Property("url");
 147            LinkProperty.Normalize(property?.Value!, context, property);
 48
 149            var titlesObject = property.Value;
 50
 151            Assert.Equal("http://example.com/table.csv", property.Value);
 52
 53
 154        }
 55
 56    }
 57}