示例#1
0
        public void GivenPageTypePropertyDefinitionWithTypeSet_GetPropertyType_ReturnsThatType()
        {
            PageDefinitionTypeMapper   mapper     = new PageDefinitionTypeMapper(null, new NativePageDefinitionsMap());
            PageTypePropertyDefinition definition = PageDefinitionSynchronizationEngineTestsUtility.CreatePageTypePropertyDefinition();

            definition.PageTypePropertyAttribute.Type = typeof(PropertyImageUrl);

            Type returnedType = mapper.GetPropertyType(definition.PropertyType, definition.PageTypePropertyAttribute);

            Assert.Equal <Type>(definition.PageTypePropertyAttribute.Type, returnedType);
        }
示例#2
0
        public void GivenPageTypePropertyDefinition_GetPageDefinitionType_CallsGetPropertyType()
        {
            PageTypePropertyDefinition   definition               = PageDefinitionSynchronizationEngineTestsUtility.CreatePageTypePropertyDefinition();
            MockRepository               fakes                    = new MockRepository();
            PageDefinitionTypeRepository fakeRepository           = fakes.Stub <PageDefinitionTypeRepository>();
            PageDefinitionTypeMapper     pageDefinitionTypeMapper = fakes.PartialMock <PageDefinitionTypeMapper>(fakeRepository, new NativePageDefinitionsMap());
            Type type = typeof(string);

            pageDefinitionTypeMapper.Stub(mapper => mapper.GetPropertyType(definition.PropertyType, definition.PageTypePropertyAttribute)).Return(type);
            fakes.ReplayAll();

            pageDefinitionTypeMapper.GetPageDefinitionType(definition);

            pageDefinitionTypeMapper.AssertWasCalled(mapper => mapper.GetPropertyType(definition.PropertyType, definition.PageTypePropertyAttribute));
        }
示例#3
0
        public void GivenPageTypePropertyDefinitionWithNoTypeSet_GetPropertyType_GetsDefaultPropertyTypeForDefinitionsPropertyType()
        {
            PageTypePropertyDefinition definition = PageDefinitionSynchronizationEngineTestsUtility.CreatePageTypePropertyDefinition();

            definition.PageTypePropertyAttribute.Type = null;
            MockRepository           fakes = new MockRepository();
            PageDefinitionTypeMapper pageDefinitionTypeMapper = fakes.PartialMock <PageDefinitionTypeMapper>((PageDefinitionTypeRepository)null, new NativePageDefinitionsMap());
            Type defaultType = typeof(string);

            pageDefinitionTypeMapper.Stub(utility => utility.GetDefaultPropertyType(definition.PropertyType)).Return(defaultType);
            pageDefinitionTypeMapper.Replay();

            Type returnedType = pageDefinitionTypeMapper.GetDefaultPropertyType(definition.PropertyType);

            pageDefinitionTypeMapper.AssertWasCalled(utility => utility.GetDefaultPropertyType(definition.PropertyType));
            Assert.Equal <Type>(defaultType, returnedType);
        }
示例#4
0
        public void GivenPageTypePropertyDefinitionWithNativeType_GetPageDefinitionType_ReturnsCorrectPageDefinitionType()
        {
            PageTypePropertyDefinition definition = PageDefinitionSynchronizationEngineTestsUtility.CreatePageTypePropertyDefinition();

            definition.PageTypePropertyAttribute.Type = typeof(PropertyString);
            MockRepository fakes = new MockRepository();
            PageDefinitionTypeRepository fakeRepository = fakes.Stub <PageDefinitionTypeRepository>();
            PageDefinitionTypeMapper     mapper         = new PageDefinitionTypeMapper(fakeRepository, new NativePageDefinitionsMap());
            int nativeTypeID = new NativePageDefinitionsMap().GetNativeTypeID(definition.PageTypePropertyAttribute.Type);
            PageDefinitionType pageDefinitionTypeFromFactory = new PageDefinitionType(1, PropertyDataType.String, TestValueUtility.CreateRandomString());

            fakeRepository.Stub(factory => factory.GetPageDefinitionType(nativeTypeID)).Return(pageDefinitionTypeFromFactory);
            fakeRepository.Replay();

            PageDefinitionType returnedPageDefinitionType = mapper.GetPageDefinitionType(definition);

            Assert.Equal <PageDefinitionType>(pageDefinitionTypeFromFactory, returnedPageDefinitionType);
        }