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); }
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); }