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 DynamicBackingItem(int Id) { if (Id == -1) { // passing in -1 needs to return a real node, the "root" node, which has no // properties (defaults apply) but can be used to access descendants, children, etc. this.content = new NodeFactory.Node(Id); return; } var n = LegacyNodeHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); this.content = n; this.Type = DynamicBackingItemType.Content; if (n.Id == 0 && Id != 0) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = DynamicBackingItemType.Media; if (this.media == null) { this.Type = DynamicBackingItemType.Content; } return; } }
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; } } }
private PropertyResult GetPropertyInternal(string alias, ExamineBackedMedia content) { bool propertyExists = false; var prop = content.GetProperty(alias, out propertyExists); if (prop != null) { return(new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }); } else { if (alias.Substring(0, 1).ToUpper() == alias.Substring(0, 1) && !propertyExists) { prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists); if (prop != null) { return(new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }); } else { object result = null; try { result = content.GetType().InvokeMember(alias, System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic, null, content, null); } catch (MissingMethodException) { } if (result != null) { return(new PropertyResult(alias, string.Format("{0}", result), Guid.Empty) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }); } } } } return(null); }
public DynamicBackingItem(int Id, DynamicBackingItemType Type) { if (Type == DynamicBackingItemType.Media) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = Type; } else { this.content = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); this.Type = Type; } }
public DynamicBackingItem(int Id, DynamicBackingItemType Type) { NodeFactory.Node baseNode = new NodeFactory.Node(Id); if (Type == DynamicBackingItemType.Media) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = Type; } else { this.content = baseNode; this.Type = Type; } }
public DynamicBackingItem(int Id) { NodeFactory.Node baseNode = new NodeFactory.Node(Id); this.content = baseNode; this.Type = DynamicBackingItemType.Content; if (baseNode.Id == 0 && Id != 0) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = DynamicBackingItemType.Media; if (this.media == null) { this.Type = DynamicBackingItemType.Content; } return; } }
public DynamicBackingItem(int Id) { var n = CompatibilityHelper.ConvertToNode(UmbracoContext.Current.ContentCache.GetById(Id)); this.content = n; this.Type = DynamicBackingItemType.Content; if (n.Id == 0 && Id != 0) { this.media = ExamineBackedMedia.GetUmbracoMedia(Id); this.Type = DynamicBackingItemType.Media; if (this.media == null) { this.Type = DynamicBackingItemType.Content; } return; } }
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 DynamicBackingItem(ExamineBackedMedia media) { this.media = media; this.Type = DynamicBackingItemType.Media; }
private PropertyResult GetPropertyInternal(string alias, ExamineBackedMedia content) { bool propertyExists = false; var prop = content.GetProperty(alias, out propertyExists); if (prop != null) { return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { if (alias.Substring(0, 1).ToUpper() == alias.Substring(0, 1) && !propertyExists) { prop = content.GetProperty(alias.Substring(0, 1).ToLower() + alias.Substring((1)), out propertyExists); if (prop != null) { return new PropertyResult(prop) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } else { object result = null; try { result = content.GetType().InvokeMember(alias, System.Reflection.BindingFlags.GetProperty | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.Public, null, content, null); } catch (MissingMethodException) { } if (result != null) { return new PropertyResult(alias, string.Format("{0}", result)) { ContextAlias = content.NodeTypeAlias, ContextId = content.Id }; } } } } return null; }