コード例 #1
0
        public void GivenPageTypePropertyDefinition_GetPageDefinitionType_CallsGetPropertyType()
        {
            PageTypePropertyDefinition definition  = PageTypePropertyUpdaterTestsUtility.CreatePageTypePropertyDefinition();
            MockRepository             fakes       = new MockRepository();
            PageDefinitionTypeFactory  fakeFactory = fakes.Stub <PageDefinitionTypeFactory>();
            PageDefinitionTypeMapper   pageDefinitionTypeMapper = fakes.PartialMock <PageDefinitionTypeMapper>(fakeFactory);
            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));
        }
コード例 #2
0
        public void GivenPageTypePropertyDefinitionWithNoTypeSet_GetPropertyType_GetsDefaultPropertyTypeForDefinitionsPropertyType()
        {
            PageTypePropertyDefinition definition = PageTypePropertyUpdaterTestsUtility.CreatePageTypePropertyDefinition();

            definition.PageTypePropertyAttribute.Type = null;
            MockRepository           fakes = new MockRepository();
            PageDefinitionTypeMapper pageDefinitionTypeMapper = fakes.PartialMock <PageDefinitionTypeMapper>((PageDefinitionTypeFactory)null);
            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);
        }