public void ItemViewModelExtensions_ChildItems_ReturnsChildren() { var dynamicContentModel = new DynamicContentModel(); var rootContentType = TypeResolutionService.ResolveType(DynamicWidgetsHierarchicalContentTests.RootContentTypeName); dynamicContentModel.ContentType = rootContentType; var manager = DynamicModuleManager.GetManager(); var viewModel = dynamicContentModel.CreateDetailsViewModel(manager.GetDataItems(rootContentType).First()); var result = viewModel.Item.ChildItems("Child1Types"); Assert.IsNotNull(result, "ChildItems returned null when there should have been child items enumerable."); Assert.AreEqual(2, result.Count(), "ChildItems did not return the expected number of child items."); }
public void ItemViewModelExtensions_ParentItem_ReturnsParentItem() { var dynamicContentModel = new DynamicContentModel(); var child1Type = TypeResolutionService.ResolveType(DynamicWidgetsHierarchicalContentTests.Child1TypeName); var rootContentType = TypeResolutionService.ResolveType(DynamicWidgetsHierarchicalContentTests.RootContentTypeName); dynamicContentModel.ContentType = child1Type; var manager = DynamicModuleManager.GetManager(); var viewModel = dynamicContentModel.CreateDetailsViewModel(manager.GetDataItems(child1Type).First()); var result = viewModel.Item.ParentItem(); Assert.IsNotNull(result, "ParentItem returned null when there should have been a parent item."); Assert.IsAssignableFrom(rootContentType, result.DataItem.GetType(), "The ParentItem result did not contain a DataItem of the expected type."); }
public void ItemViewModelExtensions_LiveParentItem_ReturnsLiveParentItem() { var dynamicContentModel = new DynamicContentModel(); var child1Type = TypeResolutionService.ResolveType(DynamicWidgetsHierarchicalContentTests.Child1TypeName); var rootContentType = TypeResolutionService.ResolveType(DynamicWidgetsHierarchicalContentTests.RootContentTypeName); dynamicContentModel.ContentType = child1Type; var manager = DynamicModuleManager.GetManager(); var liveItem = manager.Lifecycle.GetLive(manager.GetDataItems(child1Type).Where(i => i.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Master).First()); var viewModel = dynamicContentModel.CreateDetailsViewModel(liveItem); var result = viewModel.Item.ParentItem(); var lifecycleDataItem = (ILifecycleDataItem)result.DataItem; Assert.IsNotNull(result, "LiveParentItem returned null when there should have been a parent item."); Assert.IsAssignableFrom(rootContentType, result.DataItem.GetType(), "The LiveParentItem result did not contain a DataItem of the expected type."); Assert.IsNotNull(lifecycleDataItem, "DataItem is not a lifecycle data item."); Assert.AreEqual(lifecycleDataItem.Status, Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live); }