|   |  | 1 |  | using ValidateLib.Metadata.ParsingAndValidation; | 
|   |  | 2 |  | using ValidateLib.ErrorsAndWarnings.Warnings; | 
|   |  | 3 |  | using ValidateLib.TableCompatibility; | 
|   |  | 4 |  |  | 
|   |  | 5 |  | namespace CompatibilityCheckerTests | 
|   |  | 6 |  | { | 
|   |  | 7 |  |     public class NegativeTests | 
|   |  | 8 |  |     { | 
|   |  | 9 |  |         public readonly string testFilesDirectory; | 
|   | 1 | 10 |  |         public NegativeTests() | 
|   | 1 | 11 |  |         { | 
|   | 1 | 12 |  |             testFilesDirectory = Path.Combine(GetProjectDirectory(), "TestFiles"); | 
|   | 1 | 13 |  |         } | 
|   |  | 14 |  |         static string GetProjectDirectory() | 
|   | 1 | 15 |  |         { | 
|   | 1 | 16 |  |             string? currentDirectory = Directory.GetCurrentDirectory(); | 
|   |  | 17 |  |  | 
|   | 1 | 18 |  |             while (!string.IsNullOrEmpty(currentDirectory)) | 
|   | 1 | 19 |  |             { | 
|   | 1 | 20 |  |                 string[] projectFiles = Directory.GetFiles(currentDirectory, "*.csproj"); | 
|   |  | 21 |  |  | 
|   | 1 | 22 |  |                 if (projectFiles.Length > 0) | 
|   | 1 | 23 |  |                     return currentDirectory; | 
|   | 1 | 24 |  |                 currentDirectory = Directory.GetParent(currentDirectory)?.FullName; | 
|   | 1 | 25 |  |             } | 
|   |  | 26 |  |  | 
|   | 0 | 27 |  |             throw new Exception("Could not find project directory."); | 
|   | 1 | 28 |  |         } | 
|   |  | 29 |  |         [Fact] | 
|   |  | 30 |  |         public void DifferentUrlsForTableDescription() | 
|   | 1 | 31 |  |         { | 
|   | 1 | 32 |  |             var testNumber = "01"; | 
|   | 1 | 33 |  |             var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json"); | 
|   | 1 | 34 |  |             var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json"); | 
|   | 1 | 35 |  |             var warnings = new List<Warning>(); | 
|   |  | 36 |  |  | 
|   | 1 | 37 |  |             var tableDescriptor1 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 38 |  |                 warnings, | 
|   | 1 | 39 |  |                 testFilePath1 | 
|   | 1 | 40 |  |             ); | 
|   |  | 41 |  |  | 
|   | 1 | 42 |  |             var tableDescriptor2 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 43 |  |                 warnings, | 
|   | 1 | 44 |  |                 testFilePath2 | 
|   | 1 | 45 |  |                 ); | 
|   | 1 | 46 |  |             CompatibilityChecker cc = new CompatibilityChecker(); | 
|   | 1 | 47 |  |             bool result = cc.AreTableDescriptionsCompatible( tableDescriptor1, tableDescriptor2 ); | 
|   |  | 48 |  |  | 
|   | 1 | 49 |  |             Assert.False(result); | 
|   | 1 | 50 |  |         } | 
|   |  | 51 |  |  | 
|   |  | 52 |  |         [Fact] | 
|   |  | 53 |  |         public void DifferentNumberOfNonVirtualColumns() | 
|   | 1 | 54 |  |         { | 
|   | 1 | 55 |  |             var testNumber = "02"; | 
|   | 1 | 56 |  |             var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json"); | 
|   | 1 | 57 |  |             var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json"); | 
|   | 1 | 58 |  |             var warnings = new List<Warning>(); | 
|   |  | 59 |  |  | 
|   | 1 | 60 |  |             var tableDescriptor1 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 61 |  |                 warnings, | 
|   | 1 | 62 |  |                 testFilePath1 | 
|   | 1 | 63 |  |             ); | 
|   |  | 64 |  |  | 
|   | 1 | 65 |  |             var tableDescriptor2 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 66 |  |                 warnings, | 
|   | 1 | 67 |  |                 testFilePath2 | 
|   | 1 | 68 |  |                 ); | 
|   | 1 | 69 |  |             CompatibilityChecker cc = new CompatibilityChecker(); | 
|   | 1 | 70 |  |             bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2); | 
|   |  | 71 |  |  | 
|   | 1 | 72 |  |             Assert.False(result); | 
|   | 1 | 73 |  |         } | 
|   |  | 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() | 
|   | 1 | 103 |  |         { | 
|   | 1 | 104 |  |             var testNumber = "04"; | 
|   | 1 | 105 |  |             var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json"); | 
|   | 1 | 106 |  |             var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json"); | 
|   | 1 | 107 |  |             var warnings = new List<Warning>(); | 
|   |  | 108 |  |  | 
|   | 1 | 109 |  |             var tableDescriptor1 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 110 |  |                 warnings, | 
|   | 1 | 111 |  |                 testFilePath1 | 
|   | 1 | 112 |  |             ); | 
|   |  | 113 |  |  | 
|   | 1 | 114 |  |             var tableDescriptor2 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 115 |  |                 warnings, | 
|   | 1 | 116 |  |                 testFilePath2 | 
|   | 1 | 117 |  |                 ); | 
|   | 1 | 118 |  |             CompatibilityChecker cc = new CompatibilityChecker(); | 
|   | 1 | 119 |  |             bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2); | 
|   |  | 120 |  |  | 
|   | 1 | 121 |  |             Assert.False(result); | 
|   | 1 | 122 |  |         } | 
|   |  | 123 |  |  | 
|   |  | 124 |  |         [Fact] | 
|   |  | 125 |  |         public void EmptyIntersectionBetweenTitlesForColumnLangsDontMatch() | 
|   | 1 | 126 |  |         { | 
|   | 1 | 127 |  |             var testNumber = "05"; | 
|   | 1 | 128 |  |             var testFilePath1 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor1.json"); | 
|   | 1 | 129 |  |             var testFilePath2 = Path.Combine(testFilesDirectory, "test" + testNumber, "descriptor2.json"); | 
|   | 1 | 130 |  |             var warnings = new List<Warning>(); | 
|   |  | 131 |  |  | 
|   | 1 | 132 |  |             var tableDescriptor1 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 133 |  |                 warnings, | 
|   | 1 | 134 |  |                 testFilePath1 | 
|   | 1 | 135 |  |             ); | 
|   |  | 136 |  |  | 
|   | 1 | 137 |  |             var tableDescriptor2 = MetadataParserValidator.ProcessTable( | 
|   | 1 | 138 |  |                 warnings, | 
|   | 1 | 139 |  |                 testFilePath2 | 
|   | 1 | 140 |  |                 ); | 
|   | 1 | 141 |  |             CompatibilityChecker cc = new CompatibilityChecker(); | 
|   | 1 | 142 |  |             bool result = cc.AreTableDescriptionsCompatible(tableDescriptor1, tableDescriptor2); | 
|   |  | 143 |  |  | 
|   | 1 | 144 |  |             Assert.False(result); | 
|   | 1 | 145 |  |         } | 
|   |  | 146 |  |     } | 
|   |  | 147 |  | } |