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);
        }
Пример #2
0
        public static UmbracoFluentConfigurationLoader Load()
        {
            var loader = new UmbracoFluentConfigurationLoader();

            var eventConfig = loader.Add<Event>().AutoMap();
            eventConfig.Property(x => x.Title);
            eventConfig.Id(x => x.Id);
            eventConfig.Info(x => x.ContentTypeName).InfoType(UmbracoInfoType.ContentTypeName);

            return loader;
        }
        public static UmbracoFluentConfigurationLoader Load()
        {
            var loader = new UmbracoFluentConfigurationLoader();

            var eventConfig = loader.Add <Event>().AutoMap();

            eventConfig.Property(x => x.Title);
            eventConfig.Id(x => x.Id);
            eventConfig.Info(x => x.ContentTypeName).InfoType(UmbracoInfoType.ContentTypeName);

            return(loader);
        }
        public void ConfigMapProperties_MapsSinglePropertyToConfiguration()
        {
            //Assign
            StubBaseMap stubMap = new StubBaseMap();
            UmbracoFluentConfigurationLoader loader = new UmbracoFluentConfigurationLoader();
            ConfigurationMap configMap = new ConfigurationMap(new IGlassMap[] { stubMap });

            configMap.Load(loader);

            //Act
            stubMap.PerformMap(loader);

            //Assert
            Assert.AreEqual(1, stubMap.GlassType.Config.Properties.Count());
            Assert.IsNull(stubMap.GlassType.Config.VersionConfig);
        }
Пример #5
0
        public void General_RetrieveContentAndPropertiesFromUmbraco_ReturnPopulatedClass()
        {
            //Assign
            string fieldValue          = "test field value";
            string name                = "Target";
            string contentTypeAlias    = "TestType";
            string contentTypeName     = "Test Type";
            string contentTypeProperty = "TestProperty";

            var unitOfWork         = Global.CreateUnitOfWork();
            var repoFactory        = new RepositoryFactory();
            var contentService     = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                            new ContentService(unitOfWork),
                                                            new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);
            var context         = WindsorContainer.GetContext();

            var loader     = new UmbracoFluentConfigurationLoader();
            var stubConfig = loader.Add <Stub>();

            stubConfig.Configure(x =>
            {
                x.Id(y => y.Id);
                x.Id(y => y.Key);
                x.Property(y => y.TestProperty);
                x.Info(y => y.Name).InfoType(UmbracoInfoType.Name);
                x.Info(y => y.ContentTypeName).InfoType(UmbracoInfoType.ContentTypeName);
                x.Info(y => y.ContentTypeAlias).InfoType(UmbracoInfoType.ContentTypeAlias);
                x.Info(y => y.Path).InfoType(UmbracoInfoType.Path);
                x.Info(y => y.Version).InfoType(UmbracoInfoType.Version);
                x.Info(y => y.CreateDate).InfoType(UmbracoInfoType.CreateDate);
                x.Info(y => y.UpdateDate).InfoType(UmbracoInfoType.UpdateDate);
                x.Info(y => y.Creator).InfoType(UmbracoInfoType.Creator);
                x.Delegate(y => y.Delegated).GetValue(GetDelegatedValue);
            });

            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"));

            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());

            propertyType.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 <Stub>(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);
            Assert.AreEqual(content.CreateDate, result.CreateDate);
            Assert.AreEqual(content.UpdateDate, result.UpdateDate);
            Assert.AreEqual("admin", result.Creator);
            Assert.AreEqual("happy", result.Delegated);
        }
Пример #6
0
        public void General_RetrieveContentAndPropertiesFromUmbraco_ReturnPopulatedClass()
        {
            //Assign
            string fieldValue = "test field value";
            string name = "Target";
            string contentTypeAlias = "TestType";
            string contentTypeName = "Test Type";
            string contentTypeProperty = "TestProperty";

            var unitOfWork = Global.CreateUnitOfWork();
            var repoFactory = new RepositoryFactory();
            var contentService = new ContentService(unitOfWork, repoFactory);
            var contentTypeService = new ContentTypeService(unitOfWork, repoFactory,
                                                                     new ContentService(unitOfWork),
                                                                     new MediaService(unitOfWork, repoFactory));
            var dataTypeService = new DataTypeService(unitOfWork, repoFactory);
            var context = WindsorContainer.GetContext();

            var loader = new UmbracoFluentConfigurationLoader();
            var stubConfig = loader.Add<Stub>();
            stubConfig.Configure(x =>
            {
                x.Id(y => y.Id);
                x.Id(y => y.Key);
                x.Property(y => y.TestProperty);
                x.Info(y => y.Name).InfoType(UmbracoInfoType.Name);
                x.Info(y => y.ContentTypeName).InfoType(UmbracoInfoType.ContentTypeName);
                x.Info(y => y.ContentTypeAlias).InfoType(UmbracoInfoType.ContentTypeAlias);
                x.Info(y => y.Path).InfoType(UmbracoInfoType.Path);
                x.Info(y => y.Version).InfoType(UmbracoInfoType.Version);
                x.Info(y => y.CreateDate).InfoType(UmbracoInfoType.CreateDate);
                x.Info(y => y.UpdateDate).InfoType(UmbracoInfoType.UpdateDate);
                x.Info(y => y.Creator).InfoType(UmbracoInfoType.Creator);
            });

            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"));
            dataTypeService.Save(definitions.FirstOrDefault());
            var propertyType = new PropertyType(definitions.FirstOrDefault());
            propertyType.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<Stub>(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);
            Assert.AreEqual(content.CreateDate, result.CreateDate);
            Assert.AreEqual(content.UpdateDate, result.UpdateDate);
            Assert.AreEqual("admin", result.Creator);
        }