| | 1 | | using System; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using System.Linq; |
| | 4 | | using System.Text; |
| | 5 | | using System.Threading.Tasks; |
| | 6 | | using Newtonsoft.Json.Linq; |
| | 7 | | using ValidateLib.Metadata.Properties; |
| | 8 | | using ValidateLib.ErrorsAndWarnings.Warnings.SpecificWarnings; |
| | 9 | |
|
| | 10 | | namespace IRINormalizatorTests |
| | 11 | | { |
| | 12 | | public class IriExpansionTests |
| | 13 | | { |
| | 14 | | [Theory] |
| | 15 | | [InlineData("dcat:info", "http://www.w3.org/ns/dcat#info")] |
| | 16 | | [InlineData("og:info", "http://ogp.me/ns#info")] |
| | 17 | | [InlineData("rev:info", "http://purl.org/stuff/rev#info")] |
| | 18 | | [InlineData("owl:info", "http://www.w3.org/2002/07/owl#info")] |
| | 19 | | [InlineData("v:info", "http://rdf.data-vocabulary.org/#info")] |
| | 20 | | public void CorrectIriToBeExpanded(string commonPropertyIri,string expetedOutput) |
| 1 | 21 | | { |
| 1 | 22 | | CommonProperty property = new CommonProperty(commonPropertyIri, JValue.CreateNull()); |
| 1 | 23 | | var result = property.ExpandIRI(); |
| 1 | 24 | | Assert.Equal(expetedOutput, property.IRI); |
| 1 | 25 | | Assert.Null(result); |
| | 26 | |
|
| 1 | 27 | | } |
| | 28 | |
|
| | 29 | | [Theory] |
| | 30 | | [InlineData("xx::xx::x")] |
| | 31 | | [InlineData("xxxxxxx")] |
| | 32 | | public void UknownPropertyShouldReturnWarning(string commonPropertyIri) |
| 1 | 33 | | { |
| 1 | 34 | | CommonProperty property = new CommonProperty(commonPropertyIri, JValue.CreateNull()); |
| 1 | 35 | | var result = property?.ExpandIRI()?[0]; |
| 1 | 36 | | Assert.Equal(typeof(DoubleDotOrUknownPropertyWarning), result?.GetType()); |
| | 37 | |
|
| 1 | 38 | | } |
| | 39 | |
|
| | 40 | | [Theory] |
| | 41 | | [InlineData("x:x")] |
| | 42 | | [InlineData("notcorrectprefix:suffix")] |
| | 43 | | public void IncorrectPrefixShouldReturnError(string commonPropertyIri) |
| 1 | 44 | | { |
| 1 | 45 | | CommonProperty property = new CommonProperty(commonPropertyIri, JValue.CreateNull()); |
| 1 | 46 | | var result = property?.ExpandIRI()?[0]; |
| 1 | 47 | | Assert.Equal(typeof(UnkownPrefixWarning), result?.GetType()); |
| | 48 | |
|
| 1 | 49 | | } |
| | 50 | | } |
| | 51 | | } |