< Summary

Information
Class: CompatibilityCheckerTests.NegativeTests
Assembly: compatibilitycheckertests.dll
File(s): C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\CompatibilityCheckerTests\NegativeTests.cs
Line coverage
98%
Covered lines: 82
Uncovered lines: 1
Coverable lines: 83
Total lines: 147
Line coverage: 98.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

File(s)

C:\skola_karlovka\RP\code\csv-validator\CSV_Validator\Tests\CompatibilityCheckerTests\NegativeTests.cs

#LineLine coverage
 1using ValidateLib.Metadata.ParsingAndValidation;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.TableCompatibility;
 4
 5namespace CompatibilityCheckerTests
 6{
 7    public class NegativeTests
 8    {
 9        public readonly string testFilesDirectory;
 110        public NegativeTests()
 111        {
 112            testFilesDirectory = Path.Combine(GetProjectDirectory(), "TestFiles");
 113        }
 14        static string GetProjectDirectory()
 115        {
 116            string? currentDirectory = Directory.GetCurrentDirectory();
 17
 118            while (!string.IsNullOrEmpty(currentDirectory))
 119            {
 120                string[] projectFiles = Directory.GetFiles(currentDirectory, "*.csproj");
 21
 122                if (projectFiles.Length > 0)
 123                    return currentDirectory;
 124                currentDirectory = Directory.GetParent(currentDirectory)?.FullName;
 125            }
 26
 027            throw new Exception("Could not find project directory.");
 128        }
 29        [Fact]
 30        public void DifferentUrlsForTableDescription()
 131        {
 132            var testNumber = "01";
 133            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 134            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 135            var warnings = new List<Warning>();
 36
 137            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 138                warnings,
 139                testFilePath1
 140            );
 41
 142            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 143                warnings,
 144                testFilePath2
 145                );
 146            CompatibilityChecker cc = new CompatibilityChecker();
 147            bool result = cc.AreTableDescriptionsCompatible( tableDescriptor1, tableDescriptor2 );
 48
 149            Assert.False(result);
 150        }
 51
 52        [Fact]
 53        public void DifferentNumberOfNonVirtualColumns()
 154        {
 155            var testNumber = "02";
 156            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 157            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 158            var warnings = new List<Warning>();
 59
 160            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 161                warnings,
 162                testFilePath1
 163            );
 64
 165            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 166                warnings,
 167                testFilePath2
 168                );
 169            CompatibilityChecker cc = new CompatibilityChecker();
 170            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 71
 172            Assert.False(result);
 173        }
 74
 75        // based on the csvw tests this should not be an error
 76        /*
 77        [Fact]
 78        public void OneDescriptorMissingTableSchema()
 79        {
 80            var testNumber = "03";
 81            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 82            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 83            var warnings = new List<Warning>();
 84
 85            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 86                warnings,
 87                testFilePath1
 88            );
 89
 90            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 91                warnings,
 92                testFilePath2
 93                );
 94
 95            bool result = CompatibilityChecker.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 96
 97            Assert.False(result);
 98        }
 99        */
 100
 101        [Fact]
 102        public void EmptyIntersectionBetweenTitlesForColumn()
 1103        {
 1104            var testNumber = "04";
 1105            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 1106            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 1107            var warnings = new List<Warning>();
 108
 1109            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 1110                warnings,
 1111                testFilePath1
 1112            );
 113
 1114            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 1115                warnings,
 1116                testFilePath2
 1117                );
 1118            CompatibilityChecker cc = new CompatibilityChecker();
 1119            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 120
 1121            Assert.False(result);
 1122        }
 123
 124        [Fact]
 125        public void EmptyIntersectionBetweenTitlesForColumnLangsDontMatch()
 1126        {
 1127            var testNumber = "05";
 1128            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 1129            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 1130            var warnings = new List<Warning>();
 131
 1132            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 1133                warnings,
 1134                testFilePath1
 1135            );
 136
 1137            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 1138                warnings,
 1139                testFilePath2
 1140                );
 1141            CompatibilityChecker cc = new CompatibilityChecker();
 1142            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 143
 1144            Assert.False(result);
 1145        }
 146    }
 147}