コード例 #1
0
        public void TestAddRangeToIndex_InstanceOf()
        {
            //Arrange
            const string filename            = "Resources/PropertyRange-P31.nt";
            const string propertiesIndexPath = "PropertyRangeIndex_P31";
            const string entitiesIndexPath   = "PropertyRangeIndex_P31-EntitiesIndex";

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();

            //Act
            new EntitiesIndexer(filename, entitiesIndexPath).Index();
            new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index();
            var properties = new MultiLabelPropertyQuery(propertiesIndexPath, "*").Query();

            //Assert
            Assert.NotEmpty(properties);
            Assert.Single(properties); //P31

            var property31          = properties.FirstOrDefault(x => x.Id.Equals("P31"));
            var property31WithRange = property31.Range;

            //TODO: Not sure what is the correct result, but in the query results tests, this makes no sense.
            //Assert.Empty(property31WithRange);
            Assert.NotEmpty(property31WithRange);
            Assert.Contains(100, property31WithRange);
            Assert.Contains(200, property31WithRange);
            Assert.Contains(5, property31WithRange);

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();
        }
コード例 #2
0
        public void TestTopQueryPropertiesResults()
        {
            const string filename            = @"Resources/QueryPropertyWildcardAllResults.nt";
            const string propertiesIndexPath = "AllPropertiesResultsWildcardQueriesFullWord";
            const string entitiesIndexPath   = "AllPropertiesResultsWildcardQueriesFullWord_E";

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();

            new EntitiesIndexer(filename, entitiesIndexPath).Index();
            new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index();
            var actual = new MultiLabelPropertyQuery(propertiesIndexPath, "*").Query().ToArray();

            Assert.NotEmpty(actual);
            Assert.Equal("P47", actual[0].Id);  //5
            Assert.Equal("P17", actual[1].Id);  //3
            Assert.Equal("P30", actual[2].Id);  //3
            Assert.Equal("P530", actual[3].Id); //50

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();
        }
コード例 #3
0
        public void TestAddRangeToIndex()
        {
            //Arrange
            const string filename            = "Resources/PropertyRange.nt";
            const string propertiesIndexPath = "PropertyRangeIndex";
            const string entitiesIndexPath   = "PropertyRangeIndex-EntitiesIndex";

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();

            //Act
            new EntitiesIndexer(filename, entitiesIndexPath).Index();
            new PropertiesIndexer(filename, propertiesIndexPath, entitiesIndexPath).Index();
            var properties = new MultiLabelPropertyQuery(propertiesIndexPath, "*").Query().ToList();

            //Assert
            Assert.NotEmpty(properties);
            Assert.Equal(3, properties.Count); //P68, P38, P31

            var property69WithRange = properties.FirstOrDefault(x => x.Id.Equals("P69")).Range;
            var property38WithRange = properties.FirstOrDefault(x => x.Id.Equals("P38")).Range;

            Assert.NotEmpty(property69WithRange);
            Assert.Equal(902104, property69WithRange[0]);
            Assert.Equal(15936437, property69WithRange[1]);
            Assert.Equal(1188663, property69WithRange[2]);
            Assert.Equal(23002054, property69WithRange[3]);
            Assert.Equal(13220391, property69WithRange[4]);
            Assert.Equal(1321960, property69WithRange[5]);

            Assert.NotEmpty(property38WithRange);
            Assert.Equal(1643989, property38WithRange[0]);
            Assert.Equal(8142, property38WithRange[1]);
            Assert.Equal(747699, property38WithRange[2]);

            propertiesIndexPath.DeleteIfExists();
            entitiesIndexPath.DeleteIfExists();
        }