< Summary

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

#LineLine coverage
 1using ValidateLib.Metadata.ParsingAndValidation;
 2using ValidateLib.ErrorsAndWarnings.Warnings;
 3using ValidateLib.TableCompatibility;
 4
 5namespace CompatibilityCheckerTests
 6{
 7    public class PositiveTests
 8    {
 9        public readonly string testFilesDirectory;
 110        public PositiveTests()
 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 SimpleTestNamesMatch()
 131        {
 132            var testNumber = "06";
 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.True(result);
 150        }
 51
 52        [Fact]
 53        public void SimpleTestTitlesMatchUndLang()
 154        {
 155            var testNumber = "07";
 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.True(result);
 173        }
 74
 75        [Fact]
 76        public void SimpleTestTitlesMatchEnLang()
 177        {
 178            var testNumber = "08";
 179            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 180            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 181            var warnings = new List<Warning>();
 82
 183            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 184                warnings,
 185                testFilePath1
 186            );
 87
 188            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 189                warnings,
 190                testFilePath2
 191                );
 192            CompatibilityChecker cc = new CompatibilityChecker();
 193            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 94
 195            Assert.True(result);
 196        }
 97
 98        [Fact]
 99        public void SimpleTestTitlesMatchUndMatchesAll()
 1100        {
 1101            var testNumber = "09";
 1102            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 1103            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 1104            var warnings = new List<Warning>();
 105
 1106            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 1107                warnings,
 1108                testFilePath1
 1109            );
 110
 1111            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 1112                warnings,
 1113                testFilePath2
 1114                );
 1115            CompatibilityChecker cc = new CompatibilityChecker();
 1116            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 117
 1118            Assert.True(result);
 1119        }
 120
 121        [Fact]
 122        public void FindingIntersectionInMoreComplexTitlesStructures()
 1123        {
 1124            var testNumber = "09";
 1125            var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json");
 1126            var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json");
 1127            var warnings = new List<Warning>();
 128
 1129            var tableDescriptor1 = MetadataParserValidator.ProcessTable(
 1130                warnings,
 1131                testFilePath1
 1132            );
 133
 1134            var tableDescriptor2 = MetadataParserValidator.ProcessTable(
 1135                warnings,
 1136                testFilePath2
 1137                );
 1138            CompatibilityChecker cc = new CompatibilityChecker();
 1139            bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2);
 140
 1141            Assert.True(result);
 1142        }
 143    }
 144}