Beispiel #1
0
    public void GivenEmptyIndex_WhenUsingWithContentAndMediaPopulators_ThenIndexPopulated()
    {
        var mediaRebuilder = IndexInitializer.GetMediaIndexRebuilder(IndexInitializer.GetMockMediaService());

        using (GetSynchronousContentIndex(false, out var index, out var contentRebuilder, out _))
        {
            //create the whole thing
            contentRebuilder.Populate(index);
            mediaRebuilder.Populate(index);

            var result = index.Searcher.CreateQuery().All().Execute();

            Assert.AreEqual(29, result.TotalItemCount);
        }
    }
Beispiel #2
0
        public void AncestorsOrSelf_With_Examine()
        {
            var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance <PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());

            using (var luceneDir = new RandomIdRamDirectory())
                using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir,
                                                                        validator: new ContentValueSetValidator(true)))
                    using (indexer.ProcessNonAsync())
                    {
                        rebuilder.RegisterIndex(indexer.Name);
                        rebuilder.Populate(indexer);


                        var ctx      = GetUmbracoContext("/test");
                        var searcher = indexer.GetSearcher();
                        var cache    = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance <IEntityXmlSerializer>(), Factory.GetInstance <IUmbracoContextAccessor>());

                        //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
                        var publishedMedia = cache.GetById(3113);
                        var ancestors      = publishedMedia.AncestorsOrSelf();
                        Assert.IsTrue(ancestors.Select(x => x.Id).ContainsAll(new[] { 3113, 2112, 2222, 1111 }));
                    }
        }
Beispiel #3
0
        public void Do_Not_Find_In_Recycle_Bin()
        {
            var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance <PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());

            using (var luceneDir = new RandomIdRamDirectory())
                using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir,
                                                                        //include unpublished content since this uses the 'internal' indexer, it's up to the media cache to filter
                                                                        validator: new ContentValueSetValidator(false)))
                    using (indexer.ProcessNonAsync())
                    {
                        rebuilder.RegisterIndex(indexer.Name);
                        rebuilder.Populate(indexer);

                        var searcher = indexer.GetSearcher();
                        var ctx      = GetUmbracoContext("/test");
                        var cache    = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance <IEntityXmlSerializer>(), Factory.GetInstance <IUmbracoContextAccessor>());

                        //ensure it is found
                        var publishedMedia = cache.GetById(3113);
                        Assert.IsNotNull(publishedMedia);

                        //move item to recycle bin
                        var newXml = XElement.Parse(@"<node id='3113' key='5b3e46ab-3e37-4cfa-ab70-014234b5bd33' parentID='-21' level='1' writerID='0' nodeType='1032' template='0' sortOrder='2' createDate='2010-05-19T17:32:46' updateDate='2010-05-19T17:32:46' nodeName='Another Umbraco Image' urlName='acnestressscrub' writerName='Administrator' nodeTypeAlias='Image' path='-1,-21,3113'>
                    <data alias='umbracoFile'><![CDATA[/media/1234/blah.pdf]]></data>
                    <data alias='umbracoWidth'>115</data>
                    <data alias='umbracoHeight'>268</data>
                    <data alias='umbracoBytes'>10726</data>
                    <data alias='umbracoExtension'>jpg</data>
                </node>");
                        indexer.IndexItems(new[] { newXml.ConvertToValueSet("media") });


                        //ensure it still exists in the index (raw examine search)
                        var criteria = searcher.CreateQuery();
                        var filter   = criteria.Id(3113);
                        var found    = filter.Execute();
                        Assert.IsNotNull(found);
                        Assert.AreEqual(1, found.TotalItemCount);

                        //ensure it does not show up in the published media store
                        var recycledMedia = cache.GetById(3113);
                        Assert.IsNull(recycledMedia);
                    }
        }
Beispiel #4
0
        public void Ensure_Children_Sorted_With_Examine()
        {
            var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance <PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());

            using (var luceneDir = new RandomIdRamDirectory())
                using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir,
                                                                        validator: new ContentValueSetValidator(true)))
                    using (indexer.ProcessNonAsync())
                    {
                        rebuilder.RegisterIndex(indexer.Name);
                        rebuilder.Populate(indexer);

                        var searcher = indexer.GetSearcher();
                        var ctx      = GetUmbracoContext("/test");
                        var cache    = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetInstance <IEntityXmlSerializer>(), Factory.GetInstance <IUmbracoContextAccessor>());

                        //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
                        var publishedMedia = cache.GetById(1111);
                        var rootChildren   = publishedMedia.Children().ToArray();
                        var currSort       = 0;
                        for (var i = 0; i < rootChildren.Count(); i++)
                        {
                            Assert.GreaterOrEqual(rootChildren[i].SortOrder, currSort);
                            currSort = rootChildren[i].SortOrder;
                        }
                    }
        }
Beispiel #5
0
        public void DescendantsOrSelf_With_Examine()
        {
            var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetInstance <PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());

            using (var luceneDir = new RandomIdRamDirectory())
                using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, luceneDir,
                                                                        validator: new ContentValueSetValidator(true)))
                    using (indexer.ProcessNonAsync())
                    {
                        rebuilder.RegisterIndex(indexer.Name);
                        rebuilder.Populate(indexer);

                        var searcher = indexer.GetSearcher();
                        var ctx      = GetUmbracoContext("/test");
                        var cache    = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, indexer, new StaticCacheProvider(), ContentTypesCache);

                        //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
                        var publishedMedia  = cache.GetById(1111);
                        var rootDescendants = publishedMedia.DescendantsOrSelf();
                        Assert.IsTrue(rootDescendants.Select(x => x.Id).ContainsAll(new[] { 1111, 2112, 2222, 1113, 1114, 1115, 1116 }));

                        var publishedChild1 = cache.GetById(2222);
                        var subDescendants  = publishedChild1.DescendantsOrSelf();
                        Assert.IsTrue(subDescendants.Select(x => x.Id).ContainsAll(new[] { 2222, 2112, 3113 }));
                    }
        }
        public void Children_With_Examine()
        {
            var rebuilder = IndexInitializer.GetMediaIndexRebuilder(Factory.GetRequiredService <PropertyEditorCollection>(), IndexInitializer.GetMockMediaService());

            using (var luceneDir = new RandomIdRamDirectory())
                using (var indexer = IndexInitializer.GetUmbracoIndexer(ProfilingLogger, HostingEnvironment, RuntimeState, luceneDir,
                                                                        validator: new ContentValueSetValidator(true)))
                    using (indexer.ProcessNonAsync())
                    {
                        rebuilder.RegisterIndex(indexer.Name);
                        rebuilder.Populate(indexer);

                        var searcher = indexer.GetSearcher();
                        var ctx      = GetUmbracoContext("/test");
                        var cache    = new PublishedMediaCache(ServiceContext.MediaService, ServiceContext.UserService, searcher, new DictionaryAppCache(), ContentTypesCache, Factory.GetRequiredService <IEntityXmlSerializer>(), Factory.GetRequiredService <IUmbracoContextAccessor>());

                        //we are using the media.xml media to test the examine results implementation, see the media.xml file in the ExamineHelpers namespace
                        var publishedMedia = cache.GetById(1111);
                        var rootChildren   = publishedMedia.Children(VariationContextAccessor);
                        Assert.IsTrue(rootChildren.Select(x => x.Id).ContainsAll(new[] { 2222, 1113, 1114, 1115, 1116 }));

                        var publishedChild1 = cache.GetById(2222);
                        var subChildren     = publishedChild1.Children(VariationContextAccessor);
                        Assert.IsTrue(subChildren.Select(x => x.Id).ContainsAll(new[] { 2112 }));
                    }
        }