コード例 #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 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();
        }