Beispiel #1
0
    public void GivenValidationParentNode_WhenContentIndexedUnderDifferentParent_DocumentIsNotIndexed()
    {
        using (GetSynchronousContentIndex(false, out var index, out _, out _, 999))
        {
            var searcher = index.Searcher;

            var contentService = new ExamineDemoDataContentService();
            //get a node from the data repo
            var node = contentService.GetPublishedContentByXPath("//*[string-length(@id)>0 and number(@id)>0]")
                       .Root
                       .Elements()
                       .First();

            var valueSet = node.ConvertToValueSet(IndexTypes.Content);

            // Ignored since the path isn't under 999
            index.IndexItems(new[] { valueSet });
            Assert.AreEqual(0, searcher.CreateQuery().Id(valueSet.Id).Execute().TotalItemCount);

            // Change so that it's under 999 and verify
            var values = valueSet.Values.ToDictionary(x => x.Key, x => x.Value.ToList());
            values["path"] = new List <object> {
                "-1,999," + valueSet.Id
            };
            var newValueSet = new ValueSet(valueSet.Id, valueSet.Category, valueSet.ItemType, values.ToDictionary(x => x.Key, x => (IEnumerable <object>)x.Value));
            index.IndexItems(new[] { newValueSet });
            Assert.AreEqual(1, searcher.CreateQuery().Id(valueSet.Id).Execute().TotalItemCount);
        }
    }