/// <summary> /// Configures the specified property info. /// </summary> /// <param name="propertyInfo">The property info.</param> /// <returns></returns> public override AbstractPropertyConfiguration Configure(PropertyInfo propertyInfo) { var config = new UmbracoParentConfiguration(); Configure(propertyInfo, config); return(config); }
public void MapToProperty_ConfigurationIsLazy_CallsCreateClassOnServiceWithIsLazy() { //Assign var contentService = new ContentService(_unitOfWork, _repoFactory); var content = contentService.GetById(new Guid("{C382AE57-D325-4357-A32A-0A959BBD4101}")); var service = Substitute.For <IUmbracoService>(); service.ContentService.Returns(contentService); var context = new UmbracoDataMappingContext(null, content, service); var config = new UmbracoParentConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); config.IsLazy = true; var mapper = new UmbracoParentMapper(); mapper.Setup(new DataMapperResolverArgs(null, config)); //Act mapper.MapToProperty(context); //Assert //ME - I am not sure why I have to use the Arg.Is but just using item.Parent as the argument fails. service.Received().CreateType(config.PropertyInfo.PropertyType, Arg.Is <IContent>(x => x.Id == content.ParentId), true, false); }
public void CanHandle_ConfigurationIsUmbracoParent_ReturnsTrue() { //Assign var config = new UmbracoParentConfiguration(); var mapper = new UmbracoParentMapper(); //Act var result = mapper.CanHandle(config, null); //Assert Assert.IsTrue(result); }
public void MapToProperty_ConfigurationSetupCorrectly_CallsCreateClassOnService() { //Assign var contentService = new ContentService(_unitOfWork, _repoFactory); var content = contentService.GetById(new Guid("{C382AE57-D325-4357-A32A-0A959BBD4101}")); var service = Substitute.For<IUmbracoService>(); service.ContentService.Returns(contentService); var context = new UmbracoDataMappingContext(null, content, service); var config = new UmbracoParentConfiguration(); config.PropertyInfo = typeof(Stub).GetProperty("Property"); var mapper = new UmbracoParentMapper(); mapper.Setup(new DataMapperResolverArgs(null, config)); //Act mapper.MapToProperty(context); //Assert //ME - I am not sure why I have to use the Arg.Is but just using item.Parent as the argument fails. service.Received().CreateType(config.PropertyInfo.PropertyType, Arg.Is<IContent>(x => x.Id == content.ParentId), false, false); }
/// <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, UmbracoParentConfiguration config) { base.Configure(propertyInfo, config); }
/// <summary> /// Configures the specified property info. /// </summary> /// <param name="propertyInfo">The property info.</param> /// <returns></returns> public override AbstractPropertyConfiguration Configure(PropertyInfo propertyInfo) { var config = new UmbracoParentConfiguration(); Configure(propertyInfo, config); return config; }
/// <summary> /// Called to map each property automatically /// </summary> /// <param name="property"></param> /// <returns></returns> protected override AbstractPropertyConfiguration AutoMapProperty(System.Reflection.PropertyInfo property) { string name = property.Name; UmbracoInfoType infoType; if (name.ToLowerInvariant() == "id") { UmbracoIdConfiguration idConfig = new UmbracoIdConfiguration(); idConfig.PropertyInfo = property; return idConfig; } if (name.ToLowerInvariant() == "parent") { UmbracoParentConfiguration parentConfig = new UmbracoParentConfiguration(); parentConfig.PropertyInfo = property; return parentConfig; } if (name.ToLowerInvariant() == "children") { UmbracoChildrenConfiguration childrenConfig = new UmbracoChildrenConfiguration(); childrenConfig.PropertyInfo = property; return childrenConfig; } if (Enum.TryParse(name, true, out infoType)) { UmbracoInfoConfiguration infoConfig = new UmbracoInfoConfiguration(); infoConfig.PropertyInfo = property; infoConfig.Type = infoType; return infoConfig; } UmbracoPropertyConfiguration fieldConfig = new UmbracoPropertyConfiguration(); fieldConfig.PropertyAlias = name; fieldConfig.PropertyInfo = property; return fieldConfig; }