public void Ensure_Result_Has_All_Values() { var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString())); var indexInit = new IndexInitializer(); var indexer = indexInit.GetUmbracoIndexer(newIndexFolder); indexer.RebuildIndex(); var searcher = indexInit.GetUmbracoSearcher(newIndexFolder); var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile()); Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalItemCount); var searchItem = result.First(); var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher); Assert.AreEqual(searchItem.Id, backedMedia.Id); Assert.AreEqual(searchItem.Fields["sortOrder"], backedMedia.SortOrder.ToString()); Assert.AreEqual(searchItem.Fields["urlName"], backedMedia.UrlName); Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["createDate"]), backedMedia.CreateDate); Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["updateDate"]), backedMedia.UpdateDate); Assert.AreEqual(Guid.Parse(searchItem.Fields["version"]), backedMedia.Version); Assert.AreEqual(searchItem.Fields["level"], backedMedia.Level.ToString()); Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.WriterID.ToString()); Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.CreatorID.ToString()); //there's only writerId in the xml Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.CreatorName); Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.WriterName); //tehre's only writer name in the xml }
public void Ensure_Children_Are_Sorted() { var newIndexFolder = new DirectoryInfo(Path.Combine("App_Data\\CWSIndexSetTest", Guid.NewGuid().ToString())); var indexInit = new IndexInitializer(); var indexer = indexInit.GetUmbracoIndexer(newIndexFolder); indexer.RebuildIndex(); var searcher = indexInit.GetUmbracoSearcher(newIndexFolder); var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile()); Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalItemCount); var searchItem = result.First(); var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher); var children = backedMedia.ChildrenAsList.Value; var currSort = 0; for (var i = 0; i < children.Count(); i++) { Assert.GreaterOrEqual(children[i].SortOrder, currSort); currSort = children[i].SortOrder; } }
public void Ensure_Result_Has_All_Values() { using (var luceneDir = new RandomIdRAMDirectory()) using (var writer = new IndexWriter(luceneDir, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), IndexWriter.MaxFieldLength.LIMITED)) using (var indexer = IndexInitializer.GetUmbracoIndexer(writer)) using (var searcher = IndexInitializer.GetUmbracoSearcher(writer)) { //var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); //var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile()); Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalItemCount); var searchItem = result.First(); var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher); Assert.AreEqual(searchItem.Id, backedMedia.Id); Assert.AreEqual(searchItem.Fields["sortOrder"], backedMedia.SortOrder.ToString()); Assert.AreEqual(searchItem.Fields["urlName"], backedMedia.UrlName); Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["createDate"]), backedMedia.CreateDate); Assert.AreEqual(DateTools.StringToDate(searchItem.Fields["updateDate"]), backedMedia.UpdateDate); Assert.AreEqual(Guid.Parse(searchItem.Fields["version"]), backedMedia.Version); Assert.AreEqual(searchItem.Fields["level"], backedMedia.Level.ToString()); Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.WriterID.ToString()); Assert.AreEqual(searchItem.Fields["writerID"], backedMedia.CreatorID.ToString()); //there's only writerId in the xml Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.CreatorName); Assert.AreEqual(searchItem.Fields["writerName"], backedMedia.WriterName); //tehre's only writer name in the xml } }
public void Ensure_Children_Are_Sorted() { using (var luceneDir = new RandomIdRAMDirectory()) using (var writer = new IndexWriter(luceneDir, new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29), IndexWriter.MaxFieldLength.LIMITED)) using (var indexer = IndexInitializer.GetUmbracoIndexer(writer)) using (var searcher = IndexInitializer.GetUmbracoSearcher(writer)) { //var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); //var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile()); Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalItemCount); var searchItem = result.First(); var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher); var children = backedMedia.ChildrenAsList.Value; var currSort = 0; Assert.Greater(children.Count, 0); for (var i = 0; i < children.Count; i++) { Assert.GreaterOrEqual(children[i].SortOrder, currSort); currSort = children[i].SortOrder; } } }
public dynamic MediaById(int Id) { var ebm = ExamineBackedMedia.GetUmbracoMedia(Id); if (ebm != null && ebm.Id == 0) { return(new DynamicNull()); } return(new DynamicMedia(new DynamicBackingItem(ebm))); }
public void Ensure_Children_Are_Sorted() { using (var luceneDir = new RAMDirectory()) { var indexer = IndexInitializer.GetUmbracoIndexer(luceneDir); indexer.RebuildIndex(); var searcher = IndexInitializer.GetUmbracoSearcher(luceneDir); var result = searcher.Search(searcher.CreateSearchCriteria().Id(1111).Compile()); Assert.IsNotNull(result); Assert.AreEqual(1, result.TotalItemCount); var searchItem = result.First(); var backedMedia = new ExamineBackedMedia(searchItem, indexer, searcher); var children = backedMedia.ChildrenAsList.Value; var currSort = 0; for (var i = 0; i < children.Count(); i++) { Assert.GreaterOrEqual(children[i].SortOrder, currSort); currSort = children[i].SortOrder; } } }