public void TestScenario4GetPropertiesForKnownSubjectObjectType() { /* In this test, I will have two "nodes" connected. * "node1" is unknown type and has a property to "node2" * "node2" is InstanceOf (Human). * I want to display all the properties that have Range Human. * * As sample database I have the following: * Q76 (Obama) -> P31 (InstanceOf) -> Q5 (Human) * Q76 (Obama) -> P27 (CountryOfCitizenship) -> Q30 (USA) * Q76 (Obama) -> Pxx (Others) -> Qxx * * Q30 (USA) -> P31 (InstanceOf) -> Q6256 (Country) * Q30 (USA) -> Pyy (Others) -> Qyy * ... * Las propiedades que se deben mostrar que: * ``` * Q30: Domain P27 * Q5: Range P27 */ const string filename = @"Resources/QueryByRangeAndProperty.nt"; const string propertiesIndexPath = "QueryByRangeAndProperty"; const string entitiesIndexPath = "QueryByDomain-EntitiesIndex"; propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); //Act: new EntitiesIndexer(filename, entitiesIndexPath).Index(); new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index(); var rangeProperties = new MultiRangePropertyQuery(propertiesIndexPath, "Q6256").Query(); var domainProperties = new MultiDomainPropertyQuery(propertiesIndexPath, "Q5").Query(); var properties = rangeProperties.Intersect(domainProperties, new PropertyComparer()).ToArray(); var entity = new SingleIdEntityQuery(entitiesIndexPath, "Q76").Query().ToList(); Assert.NotEmpty(properties); Assert.Equal(2, properties.Length); // P27, P31 Assert.Equal("P31", properties[0].Id); Assert.Equal("P27", properties[1].Id); Assert.NotEmpty(entity); Assert.Equal("P27", entity[0].Properties[0].Id); Assert.Equal("P31", entity[0].Properties[1].Id); propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); }
public void TestScenario3GetRangesForUnknownSubjectType() { /* In this test, I will have two "nodes" connected. * "node1" is unknown type and has a property to "node2" * "node2" is InstanceOf (Human). * I want to display all the properties that have Range Human. * * As sample database I have the following: * Qxx (Mother) -> P25 (MotherOf) -> Qyy * Qxx (Mother) -> P25 (MotherOf) -> Qzz * ... * Qyy -> P31 (Type) -> Q5 (Human) * ``` * El Range que debe mostrar que: * ``` * Q5: Range P25 */ const string filename = @"Resources/QueryByRange.nt"; const string propertiesIndexPath = "QueryByRange"; const string entitiesIndexPath = "QueryByRange-EntitiesIndex"; propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); //Act: new EntitiesIndexer(filename, entitiesIndexPath).Index(); new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index(); var rangeEntities = new MultiRangePropertyQuery(propertiesIndexPath, "Q5").Query().ToList(); Assert.NotEmpty(rangeEntities); Assert.Equal(2, rangeEntities.Count); // P25, P31 Assert.Equal("P31", rangeEntities[0].Id); Assert.Equal("P25", rangeEntities[1].Id); propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); }