| | 1 | | using ValidateLib.Control; |
| | 2 | | using ValidateLib.ResultCreators; |
| | 3 | | using ValidateLib.Results; |
| | 4 | | using System.Globalization; |
| | 5 | |
|
| | 6 | | namespace RealWorldDataTests |
| | 7 | | { |
| | 8 | | public class DataGovTests |
| | 9 | | { |
| | 10 | | [Fact] |
| | 11 | | public void Test01RegisteredApplications() |
| 1 | 12 | | { |
| 1 | 13 | | Controller controller = new Controller(); |
| 1 | 14 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/platformy-registrovan%C3%A9-ap |
| 1 | 15 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 16 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 17 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 18 | | } |
| | 19 | | [Fact] |
| | 20 | | public void Test02DaysInWeek() |
| 1 | 21 | | { |
| 1 | 22 | | Controller controller = new Controller(); |
| 1 | 23 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/dny-v-t%C3%BDdnu.csv-metadata. |
| 1 | 24 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 25 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 26 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 27 | | } |
| | 28 | | [Fact] |
| | 29 | | public void Test03TimesSpecification() |
| 1 | 30 | | { |
| 1 | 31 | | Controller controller = new Controller(); |
| 1 | 32 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/jin%C3%A1-%C4%8Dasov%C3%A1-spe |
| 1 | 33 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 34 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 35 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 36 | | } |
| | 37 | | [Fact] |
| | 38 | | public void Test04ThemesSpecification() |
| 1 | 39 | | { |
| 1 | 40 | | Controller controller = new Controller(); |
| 1 | 41 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/m%C3%ADra-specifikace-t%C3%A9m |
| 1 | 42 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 43 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 44 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 45 | | } |
| | 46 | | [Fact] |
| | 47 | | public void Test05Genders() |
| 1 | 48 | | { |
| 1 | 49 | | Controller controller = new Controller(); |
| 1 | 50 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/pohlav%C3%AD.csv-metadata.json |
| 1 | 51 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 52 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 53 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 54 | | } |
| | 55 | | [Fact] |
| | 56 | | public void Test06Sports() |
| 1 | 57 | | { |
| 1 | 58 | | Controller controller = new Controller(); |
| 1 | 59 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/sporty.csv-metadata.json"; |
| 1 | 60 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 61 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 62 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 63 | | } |
| | 64 | | [Fact] |
| | 65 | | public void Test07LevelsOfAccessAbility() |
| 1 | 66 | | { |
| 1 | 67 | | Controller controller = new Controller(); |
| 1 | 68 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/stupn%C4%9B-p%C5%99%C3%ADstupn |
| 1 | 69 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 70 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 71 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 72 | | } |
| | 73 | | [Fact] |
| | 74 | | public void Test08ThemesOfEvents() |
| 1 | 75 | | { |
| 1 | 76 | | Controller controller = new Controller(); |
| 1 | 77 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/t%C3%A9mata-ud%C3%A1lost%C3%AD |
| 1 | 78 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 79 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 80 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 81 | | } |
| | 82 | | [Fact] |
| | 83 | | public void Test09TypeOfSportCentre() |
| 1 | 84 | | { |
| 1 | 85 | | Controller controller = new Controller(); |
| 1 | 86 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-sportovi%C5%A1%C5%A5.csv- |
| 1 | 87 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 88 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 89 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 90 | | } |
| | 91 | | [Fact] |
| | 92 | | public void Test10TypesOfTuristPaths() |
| 1 | 93 | | { |
| 1 | 94 | | Controller controller = new Controller(); |
| 1 | 95 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-turistick%C3%BDch-c%C3%AD |
| 1 | 96 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 97 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 98 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 99 | | } |
| | 100 | | [Fact] |
| | 101 | | public void Test11SuggestionsForOpeningDataSets() |
| 1 | 102 | | { |
| 1 | 103 | | Controller controller = new Controller(); |
| 1 | 104 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/stavy-n%C3%A1vrhu-na-data-k-ot |
| 1 | 105 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 106 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 107 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 108 | | } |
| | 109 | | [Fact] |
| | 110 | | public void Test12RegisteredApplications() |
| 1 | 111 | | { |
| 1 | 112 | | Controller controller = new Controller(); |
| 1 | 113 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/stavy-registrovan%C3%A9-aplika |
| 1 | 114 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 115 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 116 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 117 | | } |
| | 118 | | [Fact] |
| | 119 | | public void Test13TypesOfWorikingRelationships() |
| 1 | 120 | | { |
| 1 | 121 | | Controller controller = new Controller(); |
| 1 | 122 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-pracovn%C3%ADch-vztah%C5% |
| 1 | 123 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 124 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 125 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 126 | | } |
| | 127 | | [Fact] |
| | 128 | | public void Test14TypesOfSortedTrash() |
| 1 | 129 | | { |
| 1 | 130 | | Controller controller = new Controller(); |
| 1 | 131 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-t%C5%99%C3%ADd%C4%9Bn%C3% |
| 1 | 132 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 133 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 134 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 135 | | } |
| | 136 | | [Fact] |
| | 137 | | public void Test15typesOfEvents() |
| 1 | 138 | | { |
| 1 | 139 | | Controller controller = new Controller(); |
| 1 | 140 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-ud%C3%A1lost%C3%AD.csv-me |
| 1 | 141 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 142 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 143 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 144 | | } |
| | 145 | | [Fact] |
| | 146 | | public void Test16TypesOfChargedServices() |
| 1 | 147 | | { |
| 1 | 148 | | Controller controller = new Controller(); |
| 1 | 149 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-zpoplatn%C4%9Bn%C3%AD-slu |
| 1 | 150 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 151 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 152 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 153 | | } |
| | 154 | | [Fact] |
| | 155 | | public void Test17LandCategoriesProtection() |
| 1 | 156 | | { |
| 1 | 157 | | Controller controller = new Controller(); |
| 1 | 158 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/kategorie-%C3%BAzemn%C3%AD-och |
| 1 | 159 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 160 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 161 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 162 | | } |
| | 163 | | [Fact] |
| | 164 | | public void Test18TypesOfWoods() |
| 1 | 165 | | { |
| 1 | 166 | | Controller controller = new Controller(); |
| 1 | 167 | | var remoteFileUrl = "https://data.dia.gov.cz/soubory/%C4%8D%C3%ADseln%C3%ADky/typy-d%C5%99evin.csv-metadata. |
| 1 | 168 | | var validationDetails = new TableGroupValidationResultDetails(); |
| 1 | 169 | | var result = controller.ProcessMetadata(remoteFileUrl); |
| 1 | 170 | | Assert.Equal(ValidationResultType.VALID, result.GetValidationResultType); |
| 1 | 171 | | } |
| | 172 | |
|
| | 173 | | /* |
| | 174 | |
|
| | 175 | | [Fact] |
| | 176 | | public void Xd() |
| | 177 | | { |
| | 178 | | // Create controller |
| | 179 | | IController controller = ControllerFactory.CreateController(); |
| | 180 | |
|
| | 181 | | string remoteMetadataURL = "https://w3c.github.io/csvw/tests/test011/tree-ops.csv-metadata.json"; |
| | 182 | | string remoteTabularURL = "https://w3c.github.io/csvw/tests/test011/tree-ops.csv"; |
| | 183 | | string localMetadaPath = @"/data/my.csv"; |
| | 184 | | string localTabularPath = @"/data/schema.json"; |
| | 185 | |
|
| | 186 | | // starts remote tabular validation |
| | 187 | | IResult result1 = controller.ProcessTabularData(remoteTabularURL); |
| | 188 | |
|
| | 189 | | // start local tabular validation |
| | 190 | | IResult result2 = controller.ProcessTabularData(localTabularPath); |
| | 191 | |
|
| | 192 | | // start remote metadata validation |
| | 193 | | IResult result3 = controller.ProcessMetadata(remoteMetadataURL); |
| | 194 | |
|
| | 195 | | // start local metadata validation |
| | 196 | | IResult result4 = controller.ProcessMetadata(localMetadaPath); |
| | 197 | |
|
| | 198 | | // review validation result |
| | 199 | | switch (result1.GetValidationResultType) |
| | 200 | | { |
| | 201 | | case ValidationResultType.VALID: |
| | 202 | | Console.WriteLine("Validated files were valid!"); |
| | 203 | | break; |
| | 204 | | case ValidationResultType.WARNING: |
| | 205 | | Console.WriteLine("Warnings occurred during the validation!"); |
| | 206 | | break; |
| | 207 | | case ValidationResultType.ERROR: |
| | 208 | | Console.WriteLine("Errors occurred during the validaiton!"); |
| | 209 | | break; |
| | 210 | | } |
| | 211 | |
|
| | 212 | | // iterate through general errors |
| | 213 | | foreach (var error in result1.GetValidationDetails.GeneralErrors) |
| | 214 | | { |
| | 215 | | Console.WriteLine(error.GetMessage(CultureInfo.CurrentCulture)); |
| | 216 | | } |
| | 217 | |
|
| | 218 | | // foreach errors related to specific table |
| | 219 | | foreach(var tableDetails in result1.GetValidationDetails.TableValidationDetails) |
| | 220 | | { |
| | 221 | | foreach(var error in tableDetails.Errors) |
| | 222 | | { |
| | 223 | | Console.WriteLine(error.GetMessage(CultureInfo.CurrentCulture)); |
| | 224 | | } |
| | 225 | | } |
| | 226 | |
|
| | 227 | | // write the results to a file |
| | 228 | | string resultPath = @"/data/result.csv"; |
| | 229 | | IResultWriter csvResultWriter = ResultWriterFactory.CreateResultWriter(ResultFileFormat.CSV); |
| | 230 | | //csvResultWriter.GenerateResult(resultPath, result1.GetValidationDetails); |
| | 231 | |
|
| | 232 | | } |
| | 233 | | */ |
| | 234 | |
|
| | 235 | | } |
| | 236 | | } |