Example #1
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("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;
            Debug.Print("INIT STRONG {0}",
                        PublishedContentType.Get(PublishedItemType.Content, "anything")
                        .PropertyTypes.Count());
        }
Example #2
0
        public override void Initialize()
        {
            // required so we can access property.Value
            PropertyValueConvertersResolver.Current = new PropertyValueConvertersResolver(new ActivatorServiceProvider(), Logger);

            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", "anything", "anything", propertyTypes);

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
            Debug.Print("INIT LIB {0}",
                        PublishedContentType.Get(PublishedItemType.Content, "anything")
                        .PropertyTypes.Count());

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

            UmbracoContext.Current = routingContext.UmbracoContext;
        }
Example #3
0
        public void Umbraco_Route_User_Defined_Controller_Action(string templateName)
        {
            // NOTE - here we create templates with crazy aliases... assuming that these
            // could exist in the database... yet creating templates should sanitize
            // aliases one way or another...

            var template  = CreateTemplate(templateName);
            var route     = RouteTable.Routes["Umbraco_default"];
            var routeData = new RouteData()
            {
                Route = route
            };
            var umbracoContext  = GetUmbracoContext("~/dummy-page", template.Id, routeData, true);
            var publishedRouter = CreatePublishedRouter();
            var frequest        = publishedRouter.CreateRequest(umbracoContext);

            frequest.PublishedContent = umbracoContext.ContentCache.GetById(1172);
            frequest.TemplateModel    = template;

            var type = new AutoPublishedContentType(22, "CustomDocument", new PublishedPropertyType[] { });

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;

            var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContext, Mock.Of <ILogger>()));

            handler.GetHandlerForRoute(umbracoContext.HttpContext.Request.RequestContext, frequest);
            Assert.AreEqual("CustomDocument", routeData.Values["controller"].ToString());
            Assert.AreEqual(
                //global::umbraco.cms.helpers.Casing.SafeAlias(template.Alias),
                template.Alias.ToSafeAlias(),
                routeData.Values["action"].ToString());
        }
Example #4
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", "anything", "anything", new PublishedPropertyType[] {});

            PublishedContentType.GetPublishedContentTypeCallback = (alias) => type;
        }
Example #5
0
        protected override void Initialize()
        {
            base.Initialize();
            var type          = new AutoPublishedContentType(22, "myType", new PublishedPropertyType[] { });
            var image         = new AutoPublishedContentType(23, "Image", new PublishedPropertyType[] { });
            var testMediaType = new AutoPublishedContentType(24, "TestMediaType", new PublishedPropertyType[] { });

            _mediaTypes = new Dictionary <string, PublishedContentType>
            {
                { type.Alias, type },
                { image.Alias, image },
                { testMediaType.Alias, testMediaType }
            };
            ContentTypesCache.GetPublishedContentTypeByAlias = alias => _mediaTypes[alias];
        }
Example #6
0
        protected override void Initialize()
        {
            base.Initialize();
            var type          = new AutoPublishedContentType(Guid.NewGuid(), 22, "myType", new PublishedPropertyType[] { });
            var image         = new AutoPublishedContentType(Guid.NewGuid(), 23, "Image", new PublishedPropertyType[] { });
            var testMediaType = new AutoPublishedContentType(Guid.NewGuid(), 24, "TestMediaType", new PublishedPropertyType[] { });

            _mediaTypes = new Dictionary <string, PublishedContentType>
            {
                { type.Alias, type },
                { image.Alias, image },
                { testMediaType.Alias, testMediaType }
            };
            ContentTypesCache.GetPublishedContentTypeByAlias = alias => _mediaTypes[alias];

            _testWriterAndCreatorId = ServiceContext.UserService.CreateUserWithIdentity("Shannon", "test").Id;
        }
Example #7
0
        protected override void Initialize()
        {
            base.Initialize();

            // need to specify a custom callback for unit tests
            // AutoPublishedContentTypes generates properties automatically

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

            var factory = new PublishedContentTypeFactory(Mock.Of <IPublishedModelFactory>(), new PropertyValueConverterCollection(Array.Empty <IPropertyValueConverter>()), dataTypeService);
            var type    = new AutoPublishedContentType(Guid.NewGuid(), 0, "anything", new PublishedPropertyType[] { });

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => GetPublishedContentTypeByAlias(alias) ?? type;
        }
        public void Umbraco_Route_User_Defined_Controller_Action(string templateName)
        {
            // NOTE - here we create templates with crazy aliases... assuming that these
            // could exist in the database... yet creating templates should sanitize
            // aliases one way or another...

            var template  = CreateTemplate(templateName);
            var route     = RouteTable.Routes["Umbraco_default"];
            var routeData = new RouteData()
            {
                Route = route
            };
            var umbracoContext  = GetUmbracoContext("~/dummy-page", template.Id, routeData, true);
            var publishedRouter = CreatePublishedRouter();
            var frequest        = publishedRouter.CreateRequest(umbracoContext);

            frequest.PublishedContent = umbracoContext.ContentCache.GetById(1172);
            frequest.TemplateModel    = template;

            var umbracoContextAccessor = new TestUmbracoContextAccessor(umbracoContext);
            var type = new AutoPublishedContentType(22, "CustomDocument", new PublishedPropertyType[] { });

            ContentTypesCache.GetPublishedContentTypeByAlias = alias => type;

            var handler = new RenderRouteHandler(umbracoContext, new TestControllerFactory(umbracoContextAccessor, Mock.Of <ILogger>(), context =>
            {
                var membershipHelper = new MembershipHelper(
                    umbracoContext.HttpContext, Mock.Of <IPublishedMemberCache>(), Mock.Of <MembershipProvider>(), Mock.Of <RoleProvider>(), Mock.Of <IMemberService>(), Mock.Of <IMemberTypeService>(), Mock.Of <IUserService>(), Mock.Of <IPublicAccessService>(), Mock.Of <AppCaches>(), Mock.Of <ILogger>());
                return(new CustomDocumentController(Factory.GetInstance <IGlobalSettings>(),
                                                    umbracoContextAccessor,
                                                    Factory.GetInstance <ServiceContext>(),
                                                    Factory.GetInstance <AppCaches>(),
                                                    Factory.GetInstance <IProfilingLogger>(),
                                                    new UmbracoHelper(Mock.Of <IPublishedContent>(), Mock.Of <ITagQuery>(), Mock.Of <ICultureDictionaryFactory>(), Mock.Of <IUmbracoComponentRenderer>(), Mock.Of <IPublishedContentQuery>(), membershipHelper)));
            }));

            handler.GetHandlerForRoute(umbracoContext.HttpContext.Request.RequestContext, frequest);
            Assert.AreEqual("CustomDocument", routeData.Values["controller"].ToString());
            Assert.AreEqual(
                //global::umbraco.cms.helpers.Casing.SafeAlias(template.Alias),
                template.Alias.ToSafeAlias(),
                routeData.Values["action"].ToString());
        }
Example #9
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("title", 0, "?"),
                new PublishedPropertyType("bodyText", 0, "?"),
                new PublishedPropertyType("author", 0, "?")
            };
            var type = new AutoPublishedContentType(0, "anything", propertyTypes);

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