コード例 #1
0
        private PageTypeUpdater CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs()
        {
            MockRepository  mocks           = new MockRepository();
            PageTypeUpdater pageTypeUpdater = mocks.PartialMock <PageTypeUpdater>(
                PageTypeDefinitionLocatorFactory.Stub(),
                new PageTypeFactory(),
                new PageTypeValueExtractor(),
                new PageTypeLocator(new PageTypeFactory()));
            PageTypeFactory pageTypeFactory = mocks.Stub <PageTypeFactory>();

            pageTypeFactory.Stub(factory => factory.Save(Arg <IPageType> .Is.Anything));
            pageTypeFactory.Replay();
            pageTypeUpdater.PageTypeFactory = pageTypeFactory;
            pageTypeUpdater.Stub(updater => updater.GetExistingPageType(Arg <PageTypeDefinition> .Is.Anything)).Return(new NativePageType());
            pageTypeUpdater.Stub(updater => updater.UpdateName(Arg <IPageType> .Is.Anything, Arg <PageTypeDefinition> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateFilename(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateSortOrder(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDescription(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateIsAvailable(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultArchivePageLink(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultChildOrderRule(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultPageName(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultPeerOrder(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultStartPublishOffset(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultStopPublishOffset(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateDefaultVisibleInMenu(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateFrame(Arg <IPageType> .Is.Anything, Arg <PageTypeAttribute> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.UpdateAvailablePageTypes(Arg <IPageType> .Is.Anything, Arg <Type[]> .Is.Anything));
            pageTypeUpdater.Stub(updater => updater.SerializeValues(Arg <IPageType> .Is.Anything)).Repeat.Once().Return(string.Empty);
            pageTypeUpdater.Stub(updater => updater.SerializeValues(Arg <IPageType> .Is.Anything)).Repeat.Once().Return("test");
            pageTypeUpdater.Replay();
            return(pageTypeUpdater);
        }
コード例 #2
0
        public void GivenPageTypeWithSpecifiedNameAndNoGuid_GetExistingPageType_ReturnsPageTypeReturnedFromPageTypeFactoryLoad()
        {
            MockRepository     mockRepository     = new MockRepository();
            Type               pageTypeType       = typeof(object);
            PageTypeDefinition pageTypeDefinition = new PageTypeDefinition
            {
                Type      = pageTypeType,
                Attribute = new PageTypeAttribute {
                    Name = Guid.NewGuid().ToString()
                }
            };
            PageTypeFactory fakePageTypeFactory = mockRepository.Stub <PageTypeFactory>();
            IPageType       pageTypeFromFactory = new NativePageType();

            pageTypeFromFactory.ID = 1;
            fakePageTypeFactory.Expect(factory => factory.Load(pageTypeDefinition.Attribute.Name)).Return(pageTypeFromFactory);
            fakePageTypeFactory.Replay();
            PageTypeUpdater pageTypeUpdater = PageTypeUpdaterFactory.Create(
                PageTypeDefinitionLocatorFactory.Stub(), fakePageTypeFactory);

            IPageType returnedPageType = pageTypeUpdater.GetExistingPageType(pageTypeDefinition);

            fakePageTypeFactory.AssertWasCalled(factory => factory.Load(pageTypeDefinition.Attribute.Name));
            Assert.Equal <int>(pageTypeFromFactory.ID, returnedPageType.ID);
        }
コード例 #3
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);
            UpdateAvailablePageTypes(pageType, attribute.AvailablePageTypes);

            string newValuesString = SerializeValues(pageType);

            if (newValuesString != oldValueString)
            {
                PageTypeFactory.Save(pageType);
            }
        }
コード例 #4
0
        protected internal virtual IPageType CreateNewPageType(PageTypeDefinition definition)
        {
            IPageType pageType = PageTypeFactory.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;

            PageTypeFactory.Save(pageType);

            return(pageType);
        }
コード例 #5
0
        public PageDefinition GetPageDefinition(string name, string pageTypeName)
        {
            var pageType = PageTypeFactory.Load(pageTypeName);

            return(PageDefinitionFactory.List(pageType.ID)
                   .Where(def => def.Name == name)
                   .FirstOrDefault());
        }
コード例 #6
0
        public void WhenPageTypeFactoryPropertySet_SetsPageTypeFactoryPropertyValue()
        {
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            PageTypeFactory setPageTypeFactory = new PageTypeFactory();

            pageTypeUpdater.PageTypeFactory = setPageTypeFactory;

            Assert.Equal <IPageTypeFactory>(setPageTypeFactory, pageTypeUpdater.PageTypeFactory);
        }
コード例 #7
0
        private void SetupPageTypeUpdaterWithFakePageTypeFactory(PageTypeUpdater pageTypeUpdater)
        {
            MockRepository  mocks = new MockRepository();
            PageTypeFactory fakePageTypeFactory = mocks.Stub <PageTypeFactory>();

            fakePageTypeFactory.Stub(factory => factory.Save(Arg <IPageType> .Is.NotNull));
            fakePageTypeFactory.Stub(factory => factory.CreateNew()).Return(new NativePageType());
            fakePageTypeFactory.Replay();
            pageTypeUpdater.PageTypeFactory = fakePageTypeFactory;
        }
コード例 #8
0
 protected internal virtual void SortPageTypesAlphabetically()
 {
     _pageTypeDefinitions = _pageTypeDefinitions.OrderBy(p => p.GetPageTypeName());
     for (int i = 0; i < _pageTypeDefinitions.Count(); i++)
     {
         IPageType pageType = GetExistingPageType(_pageTypeDefinitions.ElementAt(i));
         pageType.SortOrder = i;
         PageTypeFactory.Save(pageType);
     }
 }
コード例 #9
0
        public void GivenPageTypeWithNoGuidOrSpecifiedName_GetExistingPageType_ReturnsPageTypeReturnedFromPageTypeFactoryLoad()
        {
            MockRepository     mockRepository      = new MockRepository();
            PageTypeDefinition pageTypeDefinition  = PageTypeUpdaterTestsUtility.CreateBasicPageTypeDefinition();
            PageTypeFactory    fakePageTypeFactory = mockRepository.Stub <PageTypeFactory>();
            IPageType          pageTypeFromFactory = new NativePageType();

            pageTypeFromFactory.ID = 1;
            fakePageTypeFactory.Expect(factory => factory.Load(pageTypeDefinition.Type.Name)).Return(pageTypeFromFactory);
            fakePageTypeFactory.Replay();
            PageTypeUpdater pageTypeUpdater = PageTypeUpdaterFactory.Create(
                PageTypeDefinitionLocatorFactory.Stub(), fakePageTypeFactory);

            IPageType returnedPageType = pageTypeUpdater.GetExistingPageType(pageTypeDefinition);

            fakePageTypeFactory.AssertWasCalled(factory => factory.Load(pageTypeDefinition.Type.Name));
            Assert.Equal <int>(pageTypeFromFactory.ID, returnedPageType.ID);
        }
コード例 #10
0
 static PageTypeHelper()
 {
     PageTypeFactory = new PageTypeFactory();
 }