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);
        }
        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;
        }
예제 #4
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);
        }