Beispiel #1
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()
                }
            };
            PageTypeRepository fakePageTypeRepository = mockRepository.Stub <PageTypeRepository>();
            IPageType          pageTypeFromFactory    = new NativePageType();

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

            IPageType returnedPageType = pageTypeUpdater.GetExistingPageType(pageTypeDefinition);

            fakePageTypeRepository.AssertWasCalled(factory => factory.Load(pageTypeDefinition.Attribute.Name));
            Assert.Equal <int>(pageTypeFromFactory.ID, returnedPageType.ID);
        }
Beispiel #2
0
        private PageTypeUpdater CreateFakePageTypeUpdaterWithUpdatePageTypeMethodHelperStubs()
        {
            MockRepository  mocks           = new MockRepository();
            PageTypeUpdater pageTypeUpdater = mocks.PartialMock <PageTypeUpdater>(
                PageTypeDefinitionLocatorFactory.Stub(),
                new PageTypeRepository(),
                new PageTypeValueExtractor(),
                new PageTypeLocator(new PageTypeRepository()));
            PageTypeRepository pageTypeRepository = mocks.Stub <PageTypeRepository>();

            pageTypeRepository.Stub(factory => factory.Save(Arg <IPageType> .Is.Anything));
            pageTypeRepository.Replay();
            pageTypeUpdater.PageTypeRepository = pageTypeRepository;
            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);
        }
        public void WhenPageTypeFactoryPropertySet_SetsPageTypeFactoryPropertyValue()
        {
            PageTypeUpdater pageTypeUpdater = CreatePageTypeUpdater();

            PageTypeRepository setPageTypeRepository = new PageTypeRepository();
            pageTypeUpdater.PageTypeRepository = setPageTypeRepository;

            Assert.Equal<IPageTypeRepository>(setPageTypeRepository, pageTypeUpdater.PageTypeRepository);
        }
Beispiel #4
0
        private void SetupPageTypeUpdaterWithFakePageTypeFactory(PageTypeUpdater pageTypeUpdater)
        {
            MockRepository     mocks = new MockRepository();
            PageTypeRepository fakePageTypeRepository = mocks.Stub <PageTypeRepository>();

            fakePageTypeRepository.Stub(factory => factory.Save(Arg <IPageType> .Is.NotNull));
            fakePageTypeRepository.Stub(factory => factory.CreateNew()).Return(new NativePageType());
            fakePageTypeRepository.Replay();
            pageTypeUpdater.PageTypeRepository = fakePageTypeRepository;
        }
Beispiel #5
0
        public void GivenPageTypeWithNoGuidOrSpecifiedName_GetExistingPageType_ReturnsPageTypeReturnedFromPageTypeFactoryLoad()
        {
            MockRepository     mockRepository         = new MockRepository();
            PageTypeDefinition pageTypeDefinition     = PageTypeUpdaterTestsUtility.CreateBasicPageTypeDefinition();
            PageTypeRepository fakePageTypeRepository = mockRepository.Stub <PageTypeRepository>();
            IPageType          pageTypeFromFactory    = new NativePageType();

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

            IPageType returnedPageType = pageTypeUpdater.GetExistingPageType(pageTypeDefinition);

            fakePageTypeRepository.AssertWasCalled(factory => factory.Load(pageTypeDefinition.Type.Name));
            Assert.Equal <int>(pageTypeFromFactory.ID, returnedPageType.ID);
        }
 static PageTypeHelper()
 {
     PageTypeRepository = new PageTypeRepository();
 }