protected override void Initialize()
        {
            base.Initialize();

            var factory = Factory.GetInstance <IPublishedContentTypeFactory>() as PublishedContentTypeFactory;

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
            {
                // AutoPublishedContentType will auto-generate other properties
                yield return(factory.CreatePropertyType(contentType, "umbracoNaviHide", 1001));

                yield return(factory.CreatePropertyType(contentType, "selectedNodes", 1));

                yield return(factory.CreatePropertyType(contentType, "umbracoUrlAlias", 1));

                yield return(factory.CreatePropertyType(contentType, "content", 1002));

                yield return(factory.CreatePropertyType(contentType, "testRecursive", 1));
            }

            var compositionAliases = new[] { "MyCompositionAlias" };
            var anythingType       = new AutoPublishedContentType(0, "anything", compositionAliases, CreatePropertyTypes);
            var homeType           = new AutoPublishedContentType(0, "home", compositionAliases, CreatePropertyTypes);

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => alias.InvariantEquals("home") ? homeType : anythingType;
        }
        public override void Initialize()
        {
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();

            // this is so the model factory looks into the test assembly
            _pluginManager = PluginManager.Current;
            PluginManager.Current = new PluginManager(false)
            {
                AssembliesToScan = _pluginManager.AssembliesToScan
                    .Union(new[] { typeof(PublishedContentTests).Assembly })
            };

            ApplicationContext.Current = new ApplicationContext(false) { IsReady = true };

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
                {
                    // AutoPublishedContentType will auto-generate other properties
                    new PublishedPropertyType("umbracoNaviHide", 0, Guid.Parse(Constants.PropertyEditors.TrueFalse)), 
                    new PublishedPropertyType("selectedNodes", 0, Guid.Empty), 
                    new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty), 
                    new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), 
                    new PublishedPropertyType("testRecursive", 0, Guid.Empty), 
                };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
        public override void Initialize()
        {
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();

            // this is so the model factory looks into the test assembly
            _pluginManager        = PluginManager.Current;
            PluginManager.Current = new PluginManager(new ActivatorServiceProvider(), CacheHelper.RuntimeCache, ProfilingLogger, false)
            {
                AssembliesToScan = _pluginManager.AssembliesToScan
                                   .Union(new[] { typeof(PublishedContentTests).Assembly })
            };

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                new PublishedPropertyType("umbracoNaviHide", 0, Constants.PropertyEditors.TrueFalseAlias),
                new PublishedPropertyType("selectedNodes", 0, "?"),
                new PublishedPropertyType("umbracoUrlAlias", 0, "?"),
                new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias),
                new PublishedPropertyType("testRecursive", 0, "?"),
            };
            var compositionAliases = new[] { "MyCompositionAlias" };
            var type = new AutoPublishedContentType(0, "anything", compositionAliases, propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
Example #4
0
        public override void Initialize()
		{
            // required so we can access property.Value
            PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();
            
            base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
                {
                    // AutoPublishedContentType will auto-generate other properties
                    new PublishedPropertyType("content", 0, "?"), 
                };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
            Console.WriteLine("INIT LIB {0}",
                PublishedContentType.Get(PublishedItemType.Content, "anything")
                    .PropertyTypes.Count());
            
            var routingContext = GetRoutingContext("/test", 1234);
			UmbracoContext.Current = routingContext.UmbracoContext;
		}
        protected override void Initialize()
        {
            base.Initialize();

            var converters             = Factory.GetInstance <PropertyValueConverterCollection>();
            var umbracoContextAccessor = Mock.Of <IUmbracoContextAccessor>();
            var logger = Mock.Of <ILogger>();

            var imageSourceParser = new HtmlImageSourceParser(umbracoContextAccessor);
            var pastedImages      = new RichTextEditorPastedImages(umbracoContextAccessor, logger, Mock.Of <IMediaService>(), Mock.Of <IContentTypeBaseServiceProvider>());
            var localLinkParser   = new HtmlLocalLinkParser(umbracoContextAccessor);
            var dataTypeService   = new TestObjects.TestDataTypeService(
                new DataType(new RichTextPropertyEditor(logger, umbracoContextAccessor, imageSourceParser, localLinkParser, pastedImages, Mock.Of <IImageUrlGenerator>()))
            {
                Id = 1
            });

            var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of <IPublishedModelFactory>(), converters, dataTypeService);

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
            {
                yield return(publishedContentTypeFactory.CreatePropertyType(contentType, "content", 1));
            }

            var type = new AutoPublishedContentType(0, "anything", CreatePropertyTypes);

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;

            var umbracoContext = GetUmbracoContext("/test");

            Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
        }
        public override void Initialize()
        {
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                new PublishedPropertyType("umbracoNaviHide", 0, Guid.Empty),
                new PublishedPropertyType("selectedNodes", 0, Guid.Empty),
                new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty),
                new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)),
                new PublishedPropertyType("testRecursive", 0, Guid.Empty),
                new PublishedPropertyType("siteTitle", 0, Guid.Empty),
                new PublishedPropertyType("creatorName", 0, Guid.Empty),
                new PublishedPropertyType("blah", 0, Guid.Empty),     // ugly error when that one is missing...
            };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
        public override void Initialize()
        {   
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();            

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
                {
                    // AutoPublishedContentType will auto-generate other properties
                    new PublishedPropertyType("siteDescription", 0, "?"), 
                    new PublishedPropertyType("siteName", 0, "?"), 
                    new PublishedPropertyType("articleContent", 0, "?"), 
                    new PublishedPropertyType("articleAuthor", 0, "?"), 
                    new PublishedPropertyType("articleDate", 0, "?"), 
                    new PublishedPropertyType("pageTitle", 0, "?"), 
                };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
            Console.WriteLine("INIT STRONG {0}",
                PublishedContentType.Get(PublishedItemType.Content, "anything")
                    .PropertyTypes.Count());
        }
        protected override void Initialize()
        {
            base.Initialize();

            var converters = Factory.GetInstance <PropertyValueConverterCollection>();

            var dataTypeService = new TestObjects.TestDataTypeService(
                new DataType(new RichTextPropertyEditor(Mock.Of <ILogger>()))
            {
                Id = 1
            });

            var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of <IPublishedModelFactory>(), converters, dataTypeService);

            // need to specify a custom callback for unit tests
            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                publishedContentTypeFactory.CreatePropertyType("content", 1),
            };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;

            var umbracoContext = GetUmbracoContext("/test");

            Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
        }
Example #9
0
        public override void Initialize()
        {
            base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            var type = new AutoPublishedContentType(0, "anything", new PublishedPropertyType[] {});
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
        public override void Initialize()
        {
            base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            var type = new AutoPublishedContentType(0, "anything", "anything", "anything", new PublishedPropertyType[] {});

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;

            // need to specify a different callback for testing
            PublishedContentExtensions.GetPropertyAliasesAndNames = s =>
            {
                var userFields = new Dictionary <string, string>()
                {
                    { "property1", "Property 1" },
                    { "property2", "Property 2" }
                };
                if (s == "Child")
                {
                    userFields.Add("property4", "Property 4");
                }
                else
                {
                    userFields.Add("property3", "Property 3");
                }

                //ensure the standard fields are there
                var allFields = new Dictionary <string, string>()
                {
                    { "Id", "Id" },
                    { "NodeName", "NodeName" },
                    { "NodeTypeAlias", "NodeTypeAlias" },
                    { "CreateDate", "CreateDate" },
                    { "UpdateDate", "UpdateDate" },
                    { "CreatorName", "CreatorName" },
                    { "WriterName", "WriterName" },
                    { "Url", "Url" }
                };
                foreach (var f in userFields.Where(f => !allFields.ContainsKey(f.Key)))
                {
                    allFields.Add(f.Key, f.Value);
                }
                return(allFields);
            };
            var routingContext = GetRoutingContext("/test");

            //set the UmbracoContext.Current since the extension methods rely on it
            UmbracoContext.Current = routingContext.UmbracoContext;
        }
		public override void Initialize()
		{
			base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            var type = new AutoPublishedContentType(0, "anything", new PublishedPropertyType[] {});
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;

            // need to specify a different callback for testing
			PublishedContentExtensions.GetPropertyAliasesAndNames = s =>
				{
					var userFields = new Dictionary<string, string>()
						{
							{"property1", "Property 1"},
							{"property2", "Property 2"}					
						};
					if (s == "Child")
					{
						userFields.Add("property4", "Property 4");
					}
					else
					{
						userFields.Add("property3", "Property 3");
					}

					//ensure the standard fields are there
					var allFields = new Dictionary<string, string>()
						{
							{"Id", "Id"},
							{"NodeName", "NodeName"},
							{"NodeTypeAlias", "NodeTypeAlias"},
							{"CreateDate", "CreateDate"},
							{"UpdateDate", "UpdateDate"},
							{"CreatorName", "CreatorName"},
							{"WriterName", "WriterName"},
							{"Url", "Url"}
						};
					foreach (var f in userFields.Where(f => !allFields.ContainsKey(f.Key)))
					{
						allFields.Add(f.Key, f.Value);
					}
					return allFields;
				};
			var routingContext = GetRoutingContext("/test");

			//set the UmbracoContext.Current since the extension methods rely on it
			UmbracoContext.Current = routingContext.UmbracoContext;
		}
        public override void Initialize()
        {
            base.Initialize();
            
            // need to specify a custom callback for unit tests
            var propertyTypes = new[]
                {
                    // AutoPublishedContentType will auto-generate other properties
                    new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)), 
                };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);
            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;

            var rCtx = GetRoutingContext("/test", 1234);
            UmbracoContext.Current = rCtx.UmbracoContext;
            
        }
        protected override void Initialize()
        {
            base.Initialize();

            var converters             = Factory.GetRequiredService <PropertyValueConverterCollection>();
            var umbracoContextAccessor = Mock.Of <IUmbracoContextAccessor>();
            var publishedUrlProvider   = Mock.Of <IPublishedUrlProvider>();
            var loggerFactory          = NullLoggerFactory.Instance;
            var serializer             = new ConfigurationEditorJsonSerializer();

            var imageSourceParser = new HtmlImageSourceParser(publishedUrlProvider);
            var mediaFileManager  = new MediaFileManager(Mock.Of <IFileSystem>(), Mock.Of <IMediaPathScheme>(),
                                                         loggerFactory.CreateLogger <MediaFileManager>(), Mock.Of <IShortStringHelper>());
            var pastedImages    = new RichTextEditorPastedImages(umbracoContextAccessor, loggerFactory.CreateLogger <RichTextEditorPastedImages>(), HostingEnvironment, Mock.Of <IMediaService>(), Mock.Of <IContentTypeBaseServiceProvider>(), mediaFileManager, ShortStringHelper, publishedUrlProvider, serializer);
            var localLinkParser = new HtmlLocalLinkParser(umbracoContextAccessor, publishedUrlProvider);
            var dataTypeService = new TestObjects.TestDataTypeService(
                new DataType(new RichTextPropertyEditor(
                                 DataValueEditorFactory,
                                 Mock.Of <IBackOfficeSecurityAccessor>(),
                                 imageSourceParser,
                                 localLinkParser,
                                 pastedImages,
                                 IOHelper,
                                 Mock.Of <IImageUrlGenerator>()),
                             serializer)
            {
                Id = 1
            });


            var publishedContentTypeFactory = new PublishedContentTypeFactory(Mock.Of <IPublishedModelFactory>(), converters, dataTypeService);

            IEnumerable <IPublishedPropertyType> CreatePropertyTypes(IPublishedContentType contentType)
            {
                yield return(publishedContentTypeFactory.CreatePropertyType(contentType, "content", 1));
            }

            var type = new AutoPublishedContentType(Guid.NewGuid(), 0, "anything", CreatePropertyTypes);

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;

            var umbracoContext = GetUmbracoContext("/test");

            Umbraco.Web.Composing.Current.UmbracoContextAccessor.UmbracoContext = umbracoContext;
        }
Example #14
0
        public override void Initialize()
        {
            base.Initialize();

            // need to specify a custom callback for unit tests
            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias),
            };
            var type = new AutoPublishedContentType(0, "anything", "anything", "anything", propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;

            var rCtx = GetRoutingContext("/test", 1234);

            UmbracoContext.Current = rCtx.UmbracoContext;
        }
        public void Children_Where_DocumentTypeAlias()
        {
            var home         = new AutoPublishedContentType(22, "Home", new PublishedPropertyType[] { });
            var custom       = new AutoPublishedContentType(23, "CustomDocument", new PublishedPropertyType[] { });
            var contentTypes = new Dictionary <string, PublishedContentType>
            {
                { home.Alias, home },
                { custom.Alias, custom }
            };

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => contentTypes[alias];

            var doc = GetNode(1046);

            var found1 = doc.Children().Where(x => x.ContentType.Alias == "CustomDocument");
            var found2 = doc.Children().Where(x => x.ContentType.Alias == "Home");

            Assert.AreEqual(1, found1.Count());
            Assert.AreEqual(2, found2.Count());
        }
        public void Children_GroupBy_DocumentTypeAlias()
        {
            var home         = new AutoPublishedContentType(22, "Home", new PublishedPropertyType[] { });
            var custom       = new AutoPublishedContentType(23, "CustomDocument", new PublishedPropertyType[] { });
            var contentTypes = new Dictionary <string, PublishedContentType>
            {
                { home.Alias, home },
                { custom.Alias, custom }
            };

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => contentTypes[alias];

            var doc = GetNode(1046);

            var found1 = doc.Children().GroupBy(x => x.ContentType.Alias).ToArray();

            Assert.AreEqual(2, found1.Length);
            Assert.AreEqual(2, found1.Single(x => x.Key.ToString() == "Home").Count());
            Assert.AreEqual(1, found1.Single(x => x.Key.ToString() == "CustomDocument").Count());
        }
        public override void Initialize()
        {
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();

            // this is so the model factory looks into the test assembly
            _pluginManager        = PluginManager.Current;
            PluginManager.Current = new PluginManager(false)
            {
                AssembliesToScan = _pluginManager.AssembliesToScan
                                   .Union(new[] { typeof(PublishedContentTests).Assembly })
            };

            ApplicationContext.Current = new ApplicationContext(false)
            {
                IsReady = true
            };

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                new PublishedPropertyType("umbracoNaviHide", 0, Guid.Parse(Constants.PropertyEditors.TrueFalse)),
                new PublishedPropertyType("selectedNodes", 0, Guid.Empty),
                new PublishedPropertyType("umbracoUrlAlias", 0, Guid.Empty),
                new PublishedPropertyType("content", 0, Guid.Parse(Constants.PropertyEditors.TinyMCEv3)),
                new PublishedPropertyType("testRecursive", 0, Guid.Empty),
            };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
        public override void Initialize()
        {
            // required so we can access property.Value
            //PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver();

            base.Initialize();

            //generate new mock settings and assign so we can configure in individual tests
            _umbracoSettings = SettingsForTests.GenerateMockSettings();
            SettingsForTests.ConfigureSettings(_umbracoSettings);

            var scriptingMock = Mock.Get(_umbracoSettings.Scripting);

            scriptingMock.Setup(x => x.DataTypeModelStaticMappings).Returns(new List <IRazorStaticMapping>());

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically
            // when they are requested, but we must declare those that we
            // explicitely want to be here...

            var propertyTypes = new[]
            {
                // AutoPublishedContentType will auto-generate other properties
                new PublishedPropertyType("umbracoNaviHide", 0, "?"),
                new PublishedPropertyType("selectedNodes", 0, "?"),
                new PublishedPropertyType("umbracoUrlAlias", 0, "?"),
                new PublishedPropertyType("content", 0, Constants.PropertyEditors.TinyMCEAlias),
                new PublishedPropertyType("testRecursive", 0, "?"),
                new PublishedPropertyType("siteTitle", 0, "?"),
                new PublishedPropertyType("creatorName", 0, "?"),
                new PublishedPropertyType("blah", 0, "?"),     // ugly error when that one is missing...
            };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }