/// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <returns></returns>
        public override Mapper.Configuration.AbstractPropertyConfiguration Configure(System.Reflection.PropertyInfo propertyInfo)
        {
            var config = new UmbracoInfoConfiguration();

            Configure(propertyInfo, config);
            return(config);
        }
        public void ConfigMapProperties_MapsAllPropertiesToConfiguration()
        {
            //Assign
            FinalStubMap    finalStubMap    = new FinalStubMap();
            PartialStub1Map partialStub1Map = new PartialStub1Map();
            StubBaseMap     stubBaseMap     = new StubBaseMap();
            PartialStub2Map partialStub2Map = new PartialStub2Map();

            UmbracoFluentConfigurationLoader loader = new UmbracoFluentConfigurationLoader();
            ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { partialStub1Map, stubBaseMap, partialStub2Map, finalStubMap });

            configMap.Load(loader);

            //Act
            finalStubMap.PerformMap(loader);
            partialStub1Map.PerformMap(loader);
            stubBaseMap.PerformMap(loader);
            partialStub2Map.PerformMap(loader);

            //Assert
            Assert.AreEqual(5, finalStubMap.GlassType.Config.Properties.Count());
            UmbracoPropertyConfiguration fieldNameProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "FieldName") as UmbracoPropertyConfiguration;

            Assert.AreEqual("Field Name", fieldNameProperty.PropertyName);

            UmbracoInfoConfiguration qwertyProperty = finalStubMap.GlassType.Config.Properties.FirstOrDefault(x => x.PropertyInfo.Name == "Qwerty") as UmbracoInfoConfiguration;

            Assert.AreEqual(UmbracoInfoType.Name, qwertyProperty.Type);

            Assert.IsNotNull(finalStubMap.GlassType.Config.IdConfig);
        }
Beispiel #3
0
        public void CanHandle_ConfigurationIsUmbracoInfo_ReturnsFalse()
        {
            //Assign
            var config = new UmbracoInfoConfiguration();
            var mapper = new UmbracoParentMapper();

            //Act
            var result = mapper.CanHandle(config, null);

            //Assert
            Assert.IsFalse(result);
        }
Beispiel #4
0
        public void MapToCms_SavingName_UpdatesTheItemName()
        {
            //Assign
            var type     = UmbracoInfoType.Name;
            var expected = "new name";

            var mapper = new UmbracoInfoMapper();
            var config = new UmbracoInfoConfiguration();

            config.Type = type;
            mapper.Setup(new DataMapperResolverArgs(null, config));

            var contentService = new ContentService(_unitOfWork, _repoFactory);
            var content        = contentService.GetById(new Guid("{FB6A8073-48B4-4B85-B80C-09CBDECC27C9}"));
            var oldName        = content.Name;

            Assert.IsNotNull(content, "Content is null, check in Umbraco that item exists");

            var resolver = DependencyResolver.CreateStandardResolver();

            resolver.Container.Register(
                Component.For <Mapper.Config>().Instance(new Mapper.Config())
                );
            var context = Context.Create(resolver);

            var dataContext = new UmbracoDataMappingContext(null, content, new UmbracoService(contentService, context), false);

            dataContext.PropertyValue = expected;

            string actual = string.Empty;

            //Act
            mapper.MapToCms(dataContext);
            content = contentService.GetById(new Guid("{FB6A8073-48B4-4B85-B80C-09CBDECC27C9}"));
            actual  = content.Name;

            //Assert
            Assert.AreEqual(expected, actual);

            content.Name = oldName;
            contentService.Save(content);
        }
        public void MapToProperty_UmbracoInfoType_GetsExpectedValueFromUmbraco(
            [Values(
                 //UmbracoInfoType.Url,
                 UmbracoInfoType.ContentTypeAlias,
                 UmbracoInfoType.ContentTypeName,
                 UmbracoInfoType.Name,
                 UmbracoInfoType.Creator
                 )] UmbracoInfoType type,
            [Values(
                 //"target", //Url
                 "TestType",  //ContentTypeAlias
                 "Test Type", //ContentTypeName
                 "Target",    //Name
                 "admin"      //Creator
                 )] object expected
            )
        {
            //Assign
            var mapper = new UmbracoInfoMapper();
            var config = new UmbracoInfoConfiguration();

            config.Type = type;
            mapper.Setup(new DataMapperResolverArgs(null, config));

            var contentService = new ContentService(_unitOfWork, _repoFactory);
            var content        = contentService.GetById(new Guid("{FB6A8073-48B4-4B85-B80C-09CBDECC27C9}"));

            Assert.IsNotNull(content, "Content is null, check in Umbraco that item exists");
            var dataContext = new UmbracoDataMappingContext(null, content, null);

            //Act
            var value = mapper.MapToProperty(dataContext);

            Console.WriteLine(type);

            //Assert
            Assert.AreEqual(expected, value);
        }
        public void MapToProperty_UmbracoInfoTypeNotSet_ThrowsException()
        {
            //Assign
            UmbracoInfoType type = UmbracoInfoType.NotSet;

            var mapper = new UmbracoInfoMapper();
            var config = new UmbracoInfoConfiguration();

            config.Type = type;
            mapper.Setup(new DataMapperResolverArgs(null, config));

            var contentService = new ContentService(_unitOfWork, _repoFactory);
            var content        = contentService.GetById(new Guid("{FB6A8073-48B4-4B85-B80C-09CBDECC27C9}"));

            Assert.IsNotNull(content, "Content is null, check in Umbraco that item exists");
            var dataContext = new UmbracoDataMappingContext(null, content, null);

            //Act
            var value = mapper.MapToProperty(dataContext);

            //Assert
            //No asserts expect exception
        }
        public void MapToProperty_UmbracoInfoTypeUpdateDate_ReturnsUpdateDateAsDateTime()
        {
            //Assign
            var type = UmbracoInfoType.UpdateDate;

            var mapper = new UmbracoInfoMapper();
            var config = new UmbracoInfoConfiguration();

            config.Type = type;
            mapper.Setup(new DataMapperResolverArgs(null, config));

            var contentService = new ContentService(_unitOfWork, _repoFactory);
            var content        = contentService.GetById(new Guid("{FB6A8073-48B4-4B85-B80C-09CBDECC27C9}"));
            var expected       = content.UpdateDate;

            Assert.IsNotNull(content, "Content is null, check in Umbraco that item exists");
            var dataContext = new UmbracoDataMappingContext(null, content, null);

            //Act
            var value = mapper.MapToProperty(dataContext);

            //Assert
            Assert.AreEqual(expected, value);
        }
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        public void Configure(PropertyInfo propertyInfo, UmbracoInfoConfiguration config)
        {
            config.Type = this.Type;

            base.Configure(propertyInfo, config);
        }
 /// <summary>
 /// Configures the specified property info.
 /// </summary>
 /// <param name="propertyInfo">The property info.</param>
 /// <returns></returns>
 public override Mapper.Configuration.AbstractPropertyConfiguration Configure(System.Reflection.PropertyInfo propertyInfo)
 {
     var config = new UmbracoInfoConfiguration();
     Configure(propertyInfo, config);
     return config;
 }
        /// <summary>
        /// Configures the specified property info.
        /// </summary>
        /// <param name="propertyInfo">The property info.</param>
        /// <param name="config">The config.</param>
        public void Configure(PropertyInfo propertyInfo, UmbracoInfoConfiguration config)
        {
            config.Type = this.Type;

            base.Configure(propertyInfo, config);
        }