public void TestScenario2GetDomainsForUnknownObjectType() { /* In this test, I will have two "nodes" connected. * "node1" is InstanceOf Human and has a second property to "node2" * "node2" is unknown type. * I want to display all the properties that have Domain Human. * * As sample I have the following: * Q76(Obama) -> P31(Type) -> Q5(Human) * Q76(Obama) -> P27 -> Qxx * Q76(Obama) -> P555 -> Qxx */ const string filename = @"Resources/QueryByDomain.nt"; const string propertiesIndexPath = "QueryByDomain"; const string entitiesIndexPath = "QueryByDomain-EntitiesIndex"; propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); //Act: new EntitiesIndexer(filename, entitiesIndexPath).Index(); new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index(); var domainProperties = new MultiDomainPropertyQuery(propertiesIndexPath, "Q5").Query().ToList(); Assert.NotEmpty(domainProperties); Assert.Equal(2, domainProperties.Count); //P27, P555 Assert.Equal("P555", domainProperties[0].Id); Assert.Equal("P27", domainProperties[1].Id); propertiesIndexPath.DeleteIfExists(); entitiesIndexPath.DeleteIfExists(); }
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(); }