public void General_RetrieveItemsAndFieldsFromUmbraco_ReturnPopulatedClass() { const string fieldValue = "test field value"; const string name = "Target"; const string contentTypeAlias = "TestType"; const string contentTypeName = "Test Type"; const string contentTypeProperty = "TestProperty"; var context = WindsorContainer.GetContext(); var loader = new UmbracoAttributeConfigurationLoader("Glass.Mapper.Umb.Integration"); context.Load(loader); IContentType contentType = new ContentType(-1); contentType.Name = contentTypeName; contentType.Alias = contentTypeAlias; contentType.Thumbnail = string.Empty; ContentTypeService.Save(contentType); Assert.Greater(contentType.Id, 0); var definitions = DataTypeService.GetDataTypeDefinitionByControlId(new Guid("ec15c1e5-9d90-422a-aa52-4f7622c63bea")); var firstDefinition = definitions.FirstOrDefault(); DataTypeService.Save(firstDefinition); var propertyType = new PropertyType(firstDefinition) { Alias = contentTypeProperty }; contentType.AddPropertyType(propertyType); ContentTypeService.Save(contentType); Assert.Greater(contentType.Id, 0); var content = new Content(name, -1, contentType); content.SetPropertyValue(contentTypeProperty, fieldValue); ContentService.Save(content); var umbracoService = new UmbracoService(ContentService, context); //Act var result = umbracoService.GetItem<AttributeStub>(content.Id); //Assert Assert.IsNotNull(result); Assert.AreEqual(fieldValue, result.TestProperty); Assert.AreEqual(content.Id, result.Id); Assert.AreEqual(content.Key, result.Key); Assert.AreEqual(name, result.Name); Assert.AreEqual(contentTypeName, result.ContentTypeName); Assert.AreEqual(content.ParentId + "," + content.Id, result.Path); Assert.AreEqual(contentTypeAlias, result.ContentTypeAlias); Assert.AreEqual(content.Version, result.Version); }
public void Load_StubClassConfigured_ReturnsStubClassAndProperties() { //Assign var loader = new UmbracoAttributeConfigurationLoader("Glass.Mapper.Umb.Tests"); //Act var results = loader.Load(); //Assert results.Count().Should().BeGreaterOrEqualTo(0); var typeConfig = results.First(x => x.Type == typeof (StubClass)); typeConfig.Should().NotBeNull(); var propertyNames = new[] {"Children", "Property", "Id", "Info", /*"Linked", "Node",*/ "Parent"/*, "Query"*/}; foreach(var propertyName in propertyNames) { var propInfo = typeof (StubClass).GetProperty(propertyName); typeConfig.Properties.Any(x=>x.PropertyInfo == propInfo).Should().BeTrue(); } }
public static IConfigurationLoader[] GlassLoaders() { var attributes = new UmbracoAttributeConfigurationLoader("Glass.Mapper.Sites.Umb"); return new IConfigurationLoader[] { attributes, ContentConfig.Load() }; }