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 }
/// <summary> /// Initializes a new instance of the <see cref="UmbracoInfoAttribute"/> class. /// </summary> /// <param name="infoType">Type of the info.</param> public UmbracoInfoAttribute(UmbracoInfoType infoType) { Type = infoType; }
/// <summary> /// The type of information that should populate the property /// </summary> /// <param name="type">The type.</param> /// <returns></returns> public UmbracoInfo <T> InfoType(UmbracoInfoType type) { Configuration.Type = type; return(this); }