示例#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);
        }
示例#2
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);
        }
示例#3
0
 private PageTypeUpdater CreatePageTypeUpdater()
 {
     return(PageTypeUpdaterFactory.Create(
                PageTypeDefinitionLocatorFactory.Stub()));
 }