Пример #1
0
        public static PageTypeAttribute CreatePageTypeAttributeWithOnlyGuidAndNameSpecified(InMemoryContext syncContext)
        {
            var pageTypeAttribute = new  PageTypeAttribute(Guid.NewGuid().ToString());

            pageTypeAttribute.Name = "Page type name";
            return(pageTypeAttribute);
        }
        protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
        {
            IPageType pageType = PageTypeRepository.CreateNew();

            PageTypeAttribute attribute = definition.Attribute;

            string name = attribute.Name;

            if (name == null)
            {
                name = definition.Type.Name;
            }
            pageType.Name = name;

            if (definition.Attribute.Guid.HasValue)
            {
                pageType.GUID = definition.Attribute.Guid.Value;
            }

            string filename = attribute.Filename;

            if (string.IsNullOrEmpty(filename))
            {
                filename = DefaultFilename;
            }
            pageType.FileName = filename;

            PageTypeRepository.Save(pageType);

            NewlyCreatedPageTypes.Add(pageType);
            return(pageType);
        }
        public static PageTypeAttribute CreatePageTypeAttributeWithEverythingSpeficied(InMemoryContext syncContext)
        {
            var guid = Guid.NewGuid();

            var pageTypeAttribute = new PageTypeAttribute(guid.ToString());
            
            var anotherPageTypeClass = syncContext.CreateAndAddPageTypeClassToAppDomain(type => { });
            var existingPageType = syncContext.PageTypeRepository.CreateNew();
            existingPageType.Name = anotherPageTypeClass.Name;
            syncContext.PageTypeRepository.Save(existingPageType);
            syncContext.PageTypeResolver.AddPageType(existingPageType.ID, anotherPageTypeClass);

            var availablePageTypes = new[] { anotherPageTypeClass };
            pageTypeAttribute.AvailablePageTypes = availablePageTypes;
            pageTypeAttribute.AvailableInEditMode = false;
            pageTypeAttribute.Description = "A description";
            pageTypeAttribute.SortOrder = 123;
            pageTypeAttribute.DefaultArchiveToPageID = 567;
            pageTypeAttribute.DefaultPageName = "Default page name";
            pageTypeAttribute.DefaultStartPublishOffsetMinutes = 1234;
            pageTypeAttribute.DefaultStopPublishOffsetMinutes = 12345;
            pageTypeAttribute.DefaultVisibleInMenu = false;
            pageTypeAttribute.DefaultChildSortOrder = FilterSortOrder.Alphabetical;
            pageTypeAttribute.DefaultSortIndex = 345;
            pageTypeAttribute.DefaultFrameID = 1;
            pageTypeAttribute.Filename = "~/TemplateForThePageType.aspx";
            pageTypeAttribute.Name = "Page type name";

            return pageTypeAttribute;
        }
        public static PageTypeAttribute CreatePageTypeAttributeWithEverythingSpeficied(InMemoryContext syncContext)
        {
            var guid = Guid.NewGuid();

            var pageTypeAttribute = new PageTypeAttribute(guid.ToString());

            var anotherPageTypeClass = syncContext.CreateAndAddPageTypeClassToAppDomain(type => { });
            var existingPageType     = syncContext.PageTypeFactory.CreateNew();

            existingPageType.Name = anotherPageTypeClass.Name;
            syncContext.PageTypeFactory.Save(existingPageType);
            syncContext.PageTypeResolver.AddPageType(existingPageType.ID, anotherPageTypeClass);

            var availablePageTypes = new[] { anotherPageTypeClass };

            pageTypeAttribute.AvailablePageTypes               = availablePageTypes;
            pageTypeAttribute.AvailableInEditMode              = false;
            pageTypeAttribute.Description                      = "A description";
            pageTypeAttribute.SortOrder                        = 123;
            pageTypeAttribute.DefaultArchiveToPageID           = 567;
            pageTypeAttribute.DefaultPageName                  = "Default page name";
            pageTypeAttribute.DefaultStartPublishOffsetMinutes = 1234;
            pageTypeAttribute.DefaultStopPublishOffsetMinutes  = 12345;
            pageTypeAttribute.DefaultVisibleInMenu             = false;
            pageTypeAttribute.DefaultChildSortOrder            = FilterSortOrder.Alphabetical;
            pageTypeAttribute.DefaultSortIndex                 = 345;
            pageTypeAttribute.DefaultFrameID                   = 1;
            pageTypeAttribute.Filename = "~/TemplateForThePageType.aspx";
            pageTypeAttribute.Name     = "Page type name";

            return(pageTypeAttribute);
        }
 protected internal virtual void UpdateFrame(IPageType pageType, PageTypeAttribute attribute)
 {
     if (attribute.DefaultFrameID != 0)
     {
         pageType.DefaultFrameID = attribute.DefaultFrameID;
     }
 }
 public static IPageType CreatePageTypeWithSameValuesAsAttribute(InMemoryContext syncContext, PageTypeAttribute pageTypeAttribute)
 {
     var pageType = syncContext.PageTypeFactory.CreateNew();
     if(pageTypeAttribute.Guid.HasValue)
         pageType.GUID = pageTypeAttribute.Guid.Value;
     pageType.AllowedPageTypes = pageTypeAttribute.AvailablePageTypes
         .Select(type => syncContext.PageTypeResolver.GetPageTypeID(type).Value).ToArray();
     pageType.Description = pageTypeAttribute.Description;
     pageType.IsAvailable = pageTypeAttribute.AvailableInEditMode;
     pageType.DefaultArchivePageLink =
         new PageReference(pageTypeAttribute.DefaultArchiveToPageID);
     pageType.SortOrder = pageTypeAttribute.SortOrder;
     pageType.DefaultPageName = pageTypeAttribute.DefaultPageName;
     pageType.DefaultStartPublishOffset =
         (pageTypeAttribute.DefaultStartPublishOffsetMinutes).Minutes();
     pageType.DefaultStopPublishOffset =
         (pageTypeAttribute.DefaultStopPublishOffsetMinutes).Minutes();
     pageType.DefaultVisibleInMenu = pageTypeAttribute.DefaultVisibleInMenu;
     pageType.DefaultPeerOrder = pageTypeAttribute.DefaultSortIndex;
     pageType.DefaultChildOrderRule = pageTypeAttribute.DefaultChildSortOrder;
     pageType.DefaultFrameID = pageTypeAttribute.DefaultFrameID;
     pageType.FileName = pageTypeAttribute.Filename;
     pageType.Name = pageTypeAttribute.Name;
     return pageType;
 }
        protected internal virtual void UpdatePageType(PageTypeDefinition definition)
        {
            IPageType         pageType       = GetExistingPageType(definition);
            PageTypeAttribute attribute      = definition.Attribute;
            string            oldValueString = SerializeValues(pageType);

            UpdateName(pageType, definition);
            UpdateFilename(pageType, attribute);
            UpdateSortOrder(pageType, attribute);
            UpdateDescription(pageType, attribute);
            UpdateIsAvailable(pageType, attribute);
            UpdateDefaultArchivePageLink(pageType, attribute);
            UpdateDefaultChildOrderRule(pageType, attribute);
            UpdateDefaultPageName(pageType, attribute);
            UpdateDefaultPeerOrder(pageType, attribute);
            UpdateDefaultStartPublishOffset(pageType, attribute);
            UpdateDefaultStopPublishOffset(pageType, attribute);
            UpdateDefaultVisibleInMenu(pageType, attribute);
            UpdateFrame(pageType, attribute);
            UpdateAvailablePageTypes(pageType, attribute.AvailablePageTypes);

            string newValuesString = SerializeValues(pageType);

            if (newValuesString != oldValueString)
            {
                PageTypeFactory.Save(pageType);
            }
        }
 public static IPageType CreatePageTypeWithEverythingButGuidDifferentThanAttribute(InMemoryContext syncContext, PageTypeAttribute pageTypeAttribute)
 {
     var pageType = syncContext.PageTypeFactory.CreateNew();
     pageType.GUID = pageTypeAttribute.Guid.Value;
     if(pageTypeAttribute.AvailablePageTypes.Length == 0)
         throw new Exception("This method only supports attributes that have atleast one type in AvailablePageTypes");
     pageType.AllowedPageTypes = new int[0];
     pageType.Description = pageTypeAttribute.Description + " more text";
     pageType.IsAvailable = !pageTypeAttribute.AvailableInEditMode;
     pageType.DefaultArchivePageLink =
         new PageReference(pageTypeAttribute.DefaultArchiveToPageID + 1);
     pageType.SortOrder = pageTypeAttribute.SortOrder + 1;
     pageType.DefaultPageName = pageTypeAttribute.DefaultPageName + " more text";
     pageType.DefaultStartPublishOffset =
         (pageTypeAttribute.DefaultStartPublishOffsetMinutes + 1).Minutes();
     pageType.DefaultStopPublishOffset =
         (pageTypeAttribute.DefaultStopPublishOffsetMinutes + 1).Minutes();
     pageType.DefaultVisibleInMenu = !pageTypeAttribute.DefaultVisibleInMenu;
     pageType.DefaultPeerOrder = pageTypeAttribute.DefaultSortIndex + 1;
     pageType.DefaultChildOrderRule = (pageTypeAttribute.DefaultChildSortOrder == FilterSortOrder.Index) 
         ? FilterSortOrder.Alphabetical 
         : FilterSortOrder.Index;
     pageType.DefaultFrameID = pageTypeAttribute.DefaultFrameID + 1;
     pageType.FileName = (pageTypeAttribute.Filename != null && pageTypeAttribute.Filename.Contains(".aspx")) 
         ? pageTypeAttribute.Filename.Replace(".aspx", "_old.aspx") 
         : "~/OldTemplateForThePageType.aspx";
     pageType.Name = pageTypeAttribute.Name + " more text";
     return pageType;
 }
        protected internal virtual void UpdateDefaultPageName(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DefaultPageNameSet))
            {
                return;
            }

            pageType.DefaultPageName = attribute.DefaultPageName;
        }
Пример #10
0
        protected internal virtual void UpdateIsAvailable(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.AvailableInEditModeSet))
            {
                return;
            }

            pageType.IsAvailable = attribute.AvailableInEditMode;
        }
Пример #11
0
        protected internal virtual void UpdateDescription(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DescriptionSet))
            {
                return;
            }

            pageType.Description = attribute.Description;
        }
Пример #12
0
        protected internal virtual void UpdateSortOrder(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.SortOrderSet))
            {
                return;
            }

            pageType.SortOrder = attribute.SortOrder;
        }
Пример #13
0
        private string GetFilename(PageTypeAttribute attribute)
        {
            string filename = attribute.Filename;

            if (string.IsNullOrEmpty(filename))
            {
                filename = DefaultFilename;
            }
            return(filename);
        }
Пример #14
0
        public void WhenUpdatePageTypeCalled_CallsUpdateFrame()
        {
            PageTypeAttribute attribute       = new PageTypeAttribute();
            IPageType         pageType        = new NativePageType();
            PageTypeUpdater   pageTypeUpdater = CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs();

            pageTypeUpdater.UpdateFrame(pageType, attribute);

            pageTypeUpdater.AssertWasCalled(updater => updater.UpdateFrame(pageType, attribute));
        }
 protected internal virtual void UpdateDefaultPeerOrder(IPageType pageType, PageTypeAttribute attribute)
 {
     if (attribute.DefaultSortIndex != PageTypeAttribute.DefaultDefaultSortIndex)
     {
         pageType.DefaultPeerOrder = attribute.DefaultSortIndex;
     }
     else
     {
         pageType.DefaultPeerOrder = DefaultDefaultPageTypePeerOrder;
     }
 }
Пример #16
0
        public void GivenAPageTypeAttribute_AttributeProperty_SetsAttributePropertyValue()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.Description = TestValueUtility.CreateRandomString();
            PageTypeDefinition pageTypeDefinition = new PageTypeDefinition();

            pageTypeDefinition.Attribute = attribute;

            Assert.Equal <PageTypeAttribute>(attribute, pageTypeDefinition.Attribute, new PageTypeAttrbitueComparer());
        }
Пример #17
0
        public void CreateAndAddPageTypeClassToAppDomain(Action <TypeSpecification, PageTypeAttribute> typeSpecificationExpression)
        {
            var  attribute     = new PageTypeAttribute();
            Type pageTypeClass = PageTypeClassFactory.CreateTypeInheritingFromTypedPageData(type =>
            {
                typeSpecificationExpression(type, attribute);
                type.AddAttributeTemplate(attribute);
            });

            AssemblyLocator.Add(pageTypeClass.Assembly);
        }
Пример #18
0
        public void GivenAttribueDefaultArchiveToPageIDIsSet_WhenUpdateDefaultArchiveToPageIDCalled_UpdatesPageTypeDefaultArchivePageLink(int archiveToPageID)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.DefaultArchiveToPageID = archiveToPageID;
            IPageType       pageType        = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultArchivePageLink(pageType, attribute);

            Assert.Equal <int>(attribute.DefaultArchiveToPageID, pageType.DefaultArchivePageLink.ID);
        }
Пример #19
0
        public void GivenValue_WhenUpdateIsAvailableCalled_UpdatesPageTypeAvailableInEditMode(bool availableInEditMode)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.AvailableInEditMode = availableInEditMode;
            IPageType       pageType        = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateIsAvailable(pageType, attribute);

            Assert.Equal <bool>(attribute.AvailableInEditMode, pageType.IsAvailable);
        }
        public void GivenNoDefaultPeerOrderRuleInAttribute_WhenUpdateDefaultPeerOrderRuleCalled_SetsPageTypeDefaultPeerOrderRuleToDefaultValue()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            IPageType         pageType  = new NativePageType();

            pageType.DefaultPeerOrder = 1;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPeerOrder(pageType, attribute);

            Assert.Equal <int>(PageTypeUpdater.DefaultDefaultPageTypePeerOrder, pageType.DefaultPeerOrder);
        }
Пример #21
0
        public void GivenSortOrder_WhenUpdateSortOrderCalled_UpdatesPageTypeSortOrder()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.SortOrder = 1;
            IPageType       pageType        = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateSortOrder(pageType, attribute);

            Assert.Equal <int>(attribute.SortOrder, pageType.SortOrder);
        }
Пример #22
0
        public void GivenDescription_UpdateDescription_UpdatesPageTypeDescription()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.Description = TestValueUtility.CreateRandomString();
            IPageType       pageType        = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDescription(pageType, attribute);

            Assert.Equal <string>(attribute.Description, pageType.Description);
        }
Пример #23
0
        protected internal virtual void UpdateFrame(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DefaultFrameIDSet))
            {
                return;
            }

            if (attribute.DefaultFrameID != 0)
            {
                pageType.DefaultFrameID = attribute.DefaultFrameID;
            }
        }
        public void GivenAttribueDefaultArchiveToPageIDPageTypeIDIsNotSet_WhenUpdateDefaultArchiveToPageIDCalled_UpdatesPageTypeDefaultArchivePageLink()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            IPageType         pageType  = new NativePageType();

            pageType.DefaultArchivePageLink = new PageReference(1);
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultArchivePageLink(pageType, attribute);

            Assert.Equal <PageReference>(null, pageType.DefaultArchivePageLink);
        }
Пример #25
0
        public void GivenNoFilenameSetInAttribute_WhenUpdatePageTypeCalled_UpdatesPageTypeFilenameWith_Filename()
        {
            PageTypeAttribute attribute       = new PageTypeAttribute();
            IPageType         pageType        = new NativePageType();
            PageTypeUpdater   pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.DefaultFilename = TestValueUtility.CreateRandomString();

            pageTypeUpdater.UpdateFilename(pageType, attribute);

            Assert.Equal <string>(pageTypeUpdater.DefaultFilename, pageType.FileName);
        }
Пример #26
0
        public void GivenFilterSortOrder_WhenUpdatePageTypeCalled_UpdatesPageTypeDefaultChildOrderRule(FilterSortOrder sortOrder)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.DefaultChildSortOrder = sortOrder;
            IPageType pageType = new NativePageType();

            pageType.DefaultChildOrderRule = FilterSortOrder.PublishedAscending;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultChildOrderRule(pageType, attribute);

            Assert.Equal <FilterSortOrder>(sortOrder, pageType.DefaultChildOrderRule);
        }
Пример #27
0
        public void GivenPageType_WhenUpdateDefaultPeerOrderRuleCalled_UpdatesPageTypeDefaultPeerOrderRule(int defaultSortIndex)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.DefaultSortIndex = defaultSortIndex;
            IPageType pageType = new NativePageType();

            pageType.DefaultPeerOrder = 1;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPeerOrder(pageType, attribute);

            Assert.Equal <int>(defaultSortIndex, pageType.DefaultPeerOrder);
        }
Пример #28
0
        public void GivenName_WhenUpdateDefaultNameCalled_UpdatesPageTypeDefaultPageName(string defaultPageName)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.DefaultPageName = defaultPageName;
            IPageType pageType = new NativePageType();

            pageType.DefaultPageName = TestValueUtility.CreateRandomString();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPageName(pageType, attribute);

            Assert.Equal <string>(defaultPageName, pageType.DefaultPageName);
        }
Пример #29
0
        protected internal virtual void UpdateDefaultPeerOrder(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DefaultSortIndexSet))
            {
                return;
            }

            if (attribute.DefaultSortIndex != PageTypeAttribute.DefaultDefaultSortIndex)
            {
                pageType.DefaultPeerOrder = attribute.DefaultSortIndex;
            }
            else
            {
                pageType.DefaultPeerOrder = DefaultDefaultPageTypePeerOrder;
            }
        }
Пример #30
0
        public void GivenAPageTypeAndANumberOfMinutes_WhenUpdateDefaultStopPublishOffsetIsCalled_ItUpdatesPageTypeDefaultStopPublishOffset(int defaultOffsetMinutes)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();

            attribute.DefaultStopPublishOffsetMinutes = defaultOffsetMinutes;
            IPageType pageType = new NativePageType();

            pageType.DefaultStopPublishOffset = new TimeSpan(0, 0, 1, 0);
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultStopPublishOffset(pageType, attribute);

            TimeSpan expectedOffset = new TimeSpan(0, 0, defaultOffsetMinutes, 0);

            Assert.Equal <TimeSpan>(expectedOffset, pageType.DefaultStopPublishOffset);
        }
Пример #31
0
        protected internal virtual void UpdateFilename(IPageType pageType, PageTypeAttribute attribute)
        {
            bool setFileName = false;

            if (string.IsNullOrEmpty(pageType.FileName))
            {
                setFileName = true;
            }

            if (!CanModifyProperty(pageType, attribute.FilenameSet) && !setFileName)
            {
                return;
            }

            string filename = GetFilename(attribute);

            pageType.FileName = filename;
        }
Пример #32
0
        protected internal virtual void UpdatePageType(PageTypeDefinition definition)
        {
            IPageType         pageType       = GetExistingPageType(definition);
            PageTypeAttribute attribute      = definition.Attribute;
            string            oldValueString = SerializeValues(pageType);

            UpdateName(pageType, definition);
            UpdateFilename(pageType, attribute);
            UpdateSortOrder(pageType, attribute);
            UpdateDescription(pageType, attribute);
            UpdateIsAvailable(pageType, attribute);
            UpdateDefaultArchivePageLink(pageType, attribute);
            UpdateDefaultChildOrderRule(pageType, attribute);
            UpdateDefaultPageName(pageType, attribute);
            UpdateDefaultPeerOrder(pageType, attribute);
            UpdateDefaultStartPublishOffset(pageType, attribute);
            UpdateDefaultStopPublishOffset(pageType, attribute);
            UpdateDefaultVisibleInMenu(pageType, attribute);
            UpdateFrame(pageType, attribute);

            bool availablePageTypesSet = false;

            if (CanModifyProperty(pageType, attribute.AvailablePageTypesSet))
            {
                UpdateAvailablePageTypes(pageType, attribute.AvailablePageTypes);

                if (attribute.AvailablePageTypes != null && attribute.AvailablePageTypes.Length > 0)
                {
                    availablePageTypesSet = true;
                }
            }

            if (!availablePageTypesSet && CanModifyProperty(pageType, attribute.ExcludedPageTypesSet) && attribute.ExcludedPageTypes != null)
            {
                UpdateAvailablePageTypesExcluded(pageType, attribute.ExcludedPageTypes);
            }

            string newValuesString = SerializeValues(pageType);

            if (newValuesString != oldValueString)
            {
                PageTypeRepository.Save(pageType);
            }
        }
Пример #33
0
        public virtual IPageType GetExistingPageType(PageTypeDefinition definition)
        {
            IPageType         existingPageType = null;
            Type              type             = definition.Type;
            PageTypeAttribute attribute        = definition.Attribute;

            if (attribute.Guid.HasValue)
            {
                existingPageType = _pageTypeFactory.Load(attribute.Guid.Value);
            }

            if (existingPageType == null && attribute.Name != null)
            {
                existingPageType = _pageTypeFactory.Load(attribute.Name);
            }

            if (existingPageType == null)
            {
                existingPageType = _pageTypeFactory.Load(type.Name);
            }

            return(existingPageType);
        }
        public void GivenDescription_UpdateDescription_UpdatesPageTypeDescription()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.Description = TestValueUtility.CreateRandomString();
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDescription(pageType, attribute);

            Assert.Equal<string>(attribute.Description, pageType.Description);
        }
        public void GivenValue_WhenUpdateIsAvailableCalled_UpdatesPageTypeAvailableInEditMode(bool availableInEditMode)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.AvailableInEditMode = availableInEditMode;
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateIsAvailable(pageType, attribute);

            Assert.Equal<bool>(attribute.AvailableInEditMode, pageType.IsAvailable);
        }
        public void GivenFilenameSetInAttribute_WhenUpdatePageTypeCalled_UpdatesPageTypeFilenameWith_Filename()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.Filename = TestValueUtility.CreateRandomString();
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateFilename(pageType, attribute);

            Assert.Equal<string>(attribute.Filename, pageType.FileName);
        }
Пример #37
0
 private string GetFilename(PageTypeAttribute attribute)
 {
     string filename = attribute.Filename;
     if (string.IsNullOrEmpty(filename))
     {
         filename = DefaultFilename;
     }
     return filename;
 }
        public void GivenPageType_WhenUpdateDefaultPeerOrderRuleCalled_UpdatesPageTypeDefaultPeerOrderRule(int defaultSortIndex)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.DefaultSortIndex = defaultSortIndex;
            IPageType pageType = new NativePageType();
            pageType.DefaultPeerOrder = 1;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPeerOrder(pageType, attribute);

            Assert.Equal<int>(defaultSortIndex, pageType.DefaultPeerOrder);
        }
        public void GivenAPageTypeAndANumberOfMinutes_WhenUpdateDefaultStopPublishOffsetIsCalled_ItUpdatesPageTypeDefaultStopPublishOffset(int defaultOffsetMinutes)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.DefaultStopPublishOffsetMinutes = defaultOffsetMinutes;
            IPageType pageType = new NativePageType();
            pageType.DefaultStopPublishOffset = new TimeSpan(0, 0, 1, 0);
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultStopPublishOffset(pageType, attribute);

            TimeSpan expectedOffset = new TimeSpan(0, 0, defaultOffsetMinutes, 0);
            Assert.Equal<TimeSpan>(expectedOffset, pageType.DefaultStopPublishOffset);
        }
Пример #40
0
 protected internal virtual void UpdateDefaultPageName(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.DefaultPageName = attribute.DefaultPageName;
 }
        public void GivenFilterSortOrder_WhenUpdatePageTypeCalled_UpdatesPageTypeDefaultChildOrderRule(FilterSortOrder sortOrder)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.DefaultChildSortOrder = sortOrder;
            IPageType pageType = new NativePageType();
            pageType.DefaultChildOrderRule = FilterSortOrder.PublishedAscending;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultChildOrderRule(pageType, attribute);

            Assert.Equal<FilterSortOrder>(sortOrder, pageType.DefaultChildOrderRule);
        }
Пример #42
0
 protected internal virtual void UpdateDefaultArchivePageLink(IPageType pageType, PageTypeAttribute attribute)
 {
     if(attribute.DefaultArchiveToPageID != PageTypeAttribute.DefaultDefaultArchiveToPageID)
         pageType.DefaultArchivePageLink = new PageReference(attribute.DefaultArchiveToPageID);
     else
         pageType.DefaultArchivePageLink = null;
 }
Пример #43
0
 protected internal virtual void UpdateDefaultChildOrderRule(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.DefaultChildOrderRule = attribute.DefaultChildSortOrder;
 }
        protected internal virtual void UpdateDefaultVisibleInMenu(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DefaultVisibleInMenuSet))
                return;

            if (attribute.DefaultVisibleInMenu != PageTypeAttribute.DefaultDefaultVisibleInMenu)
                pageType.DefaultVisibleInMenu = attribute.DefaultVisibleInMenu;
            else
                pageType.DefaultVisibleInMenu = DefaultDefaultVisibleInMenu;
        }
        protected internal virtual void UpdateFrame(IPageType pageType, PageTypeAttribute attribute)
        {
            if (!CanModifyProperty(pageType, attribute.DefaultFrameIDSet))
                return;

            if (attribute.DefaultFrameID != 0)
                pageType.DefaultFrameID = attribute.DefaultFrameID;
        }
Пример #46
0
 protected internal virtual void UpdateSortOrder(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.SortOrder = attribute.SortOrder;
 }
        public void GivenAttribueDefaultArchiveToPageIDPageTypeIDIsNotSet_WhenUpdateDefaultArchiveToPageIDCalled_UpdatesPageTypeDefaultArchivePageLink()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            IPageType pageType = new NativePageType();
            pageType.DefaultArchivePageLink = new PageReference(1);
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultArchivePageLink(pageType, attribute);

            Assert.Equal<PageReference>(null, pageType.DefaultArchivePageLink);
        }
Пример #48
0
 protected internal virtual void UpdateDefaultPeerOrder(IPageType pageType, PageTypeAttribute attribute)
 {
     if (attribute.DefaultSortIndex != PageTypeAttribute.DefaultDefaultSortIndex)
         pageType.DefaultPeerOrder = attribute.DefaultSortIndex;
     else
         pageType.DefaultPeerOrder = DefaultDefaultPageTypePeerOrder;
 }
        public void GivenAttribueDefaultArchiveToPageIDIsSet_WhenUpdateDefaultArchiveToPageIDCalled_UpdatesPageTypeDefaultArchivePageLink(int archiveToPageID)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.DefaultArchiveToPageID = archiveToPageID;
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultArchivePageLink(pageType, attribute);

            Assert.Equal<int>(attribute.DefaultArchiveToPageID, pageType.DefaultArchivePageLink.ID);
        }
Пример #50
0
 protected internal virtual void UpdateDefaultStopPublishOffset(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.DefaultStopPublishOffset = new TimeSpan(0, 0, attribute.DefaultStopPublishOffsetMinutes, 0);
 }
        public void GivenName_WhenUpdateDefaultNameCalled_UpdatesPageTypeDefaultPageName(string defaultPageName)
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.DefaultPageName = defaultPageName;
            IPageType pageType = new NativePageType();
            pageType.DefaultPageName = TestValueUtility.CreateRandomString();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPageName(pageType, attribute);

            Assert.Equal<string>(defaultPageName, pageType.DefaultPageName);
        }
Пример #52
0
 protected internal virtual void UpdateDefaultVisibleInMenu(IPageType pageType, PageTypeAttribute attribute)
 {
     if (attribute.DefaultVisibleInMenu != PageTypeAttribute.DefaultDefaultVisibleInMenu)
         pageType.DefaultVisibleInMenu = attribute.DefaultVisibleInMenu;
     else
         pageType.DefaultVisibleInMenu = DefaultDefaultVisibleInMenu;
 }
        public void GivenNoDefaultPeerOrderRuleInAttribute_WhenUpdateDefaultPeerOrderRuleCalled_SetsPageTypeDefaultPeerOrderRuleToDefaultValue()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            IPageType pageType = new NativePageType();
            pageType.DefaultPeerOrder = 1;
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateDefaultPeerOrder(pageType, attribute);

            Assert.Equal<int>(PageTypeUpdater.DefaultDefaultPageTypePeerOrder, pageType.DefaultPeerOrder);
        }
Пример #54
0
 protected internal virtual void UpdateFrame(IPageType pageType, PageTypeAttribute attribute)
 {
     if (attribute.DefaultFrameID != 0)
         pageType.DefaultFrameID = attribute.DefaultFrameID;
 }
        public void WhenUpdatePageTypeCalled_CallsUpdateFrame()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs();

            pageTypeUpdater.UpdateFrame(pageType, attribute);

            pageTypeUpdater.AssertWasCalled(updater => updater.UpdateFrame(pageType, attribute));
        }
        public void GivenSortOrder_WhenUpdateSortOrderCalled_UpdatesPageTypeSortOrder()
        {
            PageTypeAttribute attribute = new PageTypeAttribute();
            attribute.SortOrder = 1;
            IPageType pageType = new NativePageType();
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            pageTypeUpdater.UpdateSortOrder(pageType, attribute);

            Assert.Equal<int>(attribute.SortOrder, pageType.SortOrder);
        }
Пример #57
0
 protected internal virtual void UpdateDescription(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.Description = attribute.Description;
 }
Пример #58
0
 protected internal virtual void UpdateFilename(IPageType pageType, PageTypeAttribute attribute)
 {
     string filename = GetFilename(attribute);
     pageType.FileName = filename;
 }
 public static PageTypeAttribute CreatePageTypeAttributeWithOnlyGuidAndNameSpecified(InMemoryContext syncContext)
 {
     var pageTypeAttribute = new  PageTypeAttribute(Guid.NewGuid().ToString());
     pageTypeAttribute.Name = "Page type name";
     return pageTypeAttribute;
 }
Пример #60
0
 protected internal virtual void UpdateIsAvailable(IPageType pageType, PageTypeAttribute attribute)
 {
     pageType.IsAvailable = attribute.AvailableInEditMode;
 }