/*
         * == given specifications ==
         * Widget specification 1
         * ├─ Atom
         * ├─ Placeholder
         * └─ Container
         *    └─ Placeholder
         *
         * Widget specification 2
         * ├─ Atom
         * └─ Placeholder
         *
         * == and widget template ==
         * Widget (widget specification 1)
         * ├─ Area
         * │  └─ Atom
         * └─ Area
         *    ├─ Atom
         *    ├─ Atom
         *    └─ Widget (widget specification 2)
         *       └─ Area
         *          └─ Atom
         *
         * == should build to ==
         * WidgetInstance (widget specification 1)
         * ├─ AtomInstance
         * ├─ PlaceholderInstance
         * │  └─ AtomInstance
         * └─ ContainerInstance
         *    └─ PlaceholderInstance
         *       ├─ AtomInstance
         *       ├─ AtomInstance
         *       └─ WidgetInstance (widget specification 2)
         *          ├─ AtomInstance
         *          └─ PlaceholderInstance
         *             └─ Atom
         */
        public void SetUp()
        {
            var specification1 = new WidgetSpecification(
                "widget 1",
                Enumerable.Empty <PropertySpecification>(),
                new IComponent[]
            {
                new Atom("atom", Enumerable.Empty <Property>()),
                new Placeholder("area 1"),
                new Container(
                    "container",
                    Enumerable.Empty <Property>(),
                    new[] { new Placeholder("area 2") })
            });

            var specification2 = new WidgetSpecification(
                "widget 2",
                Enumerable.Empty <PropertySpecification>(),
                new IComponent[]
            {
                new Atom("atom", Enumerable.Empty <Property>()),
                new Placeholder("area 1")
            });

            var widget = new Widget(
                "widget 1",
                new[]
            {
                new Area(
                    "area 1",
                    new IComponent[]
                {
                    new Atom("atom", Enumerable.Empty <Property>())
                }),
                new Area(
                    "area 2",
                    new IComponent[]
                {
                    new Atom("atom", Enumerable.Empty <Property>()),
                    new Atom("atom", Enumerable.Empty <Property>()),
                    new Widget(
                        "widget 2",
                        new[]
                    {
                        new Area(
                            "area 1",
                            new[]
                        {
                            new Atom("atom", Enumerable.Empty <Property>())
                        })
                    })
                })
            });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), n => n == "widget 1" ? specification1 : specification2, null);

            this.instance = (WidgetInstance)widget.Build(builder, new[] { 0 }, buildContext);
        }
        public void SetUp()
        {
            var atom = new Atom(
                "atom",
                new[] { new Property("property-name", "property-type", new InheritedPropertyValue("property-name")) });

            var parentSpecification = new ContainerSpecification("parent-container");

            var grandparentSpecification = new ContainerSpecification("grandparent-container");

            grandparentSpecification.AddProperty(new PropertySpecification("property-name", "property-type", string.Empty));

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var parent = parentSpecification.Create();

            parent.Insert(0, atom);

            var grandparent = grandparentSpecification.Create();

            grandparent.FindOrCreateProperty(new PropertySpecification("property-name", "property-type", string.Empty));
            grandparent.Properties.Single().Value = new FixedPropertyValue("property-value");
            grandparent.Insert(0, parent);

            var builder = new Builder(RenderingInstructions.BuildForPreview(), null, null);

            this.instance = grandparent.Build(builder, new[] { 0 }, buildContext);
        }
Example #3
0
        public void SetUp()
        {
            var atom = new Atom(
                "atom",
                new[] { new Property("property-name", "property-type", new InheritedPropertyValue("property-alias")) });

            var containerSpecification = new ContainerSpecification("container");
            var container = containerSpecification.Create();

            container.Insert(0, atom);

            var widgetSpecification = new WidgetSpecification(
                "widget",
                new[] { new PropertySpecification("property-alias", "property-type", string.Empty) },
                new[] { container });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var widget = widgetSpecification.Create();

            widget.FindOrCreateProperty(new PropertySpecification("property-alias", "property-type", string.Empty));
            widget.Properties.Single().Value = new FixedPropertyValue("property-value");

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            this.instance = widget.Build(builder, new[] { 0 }, buildContext);
        }
        public void SetUp()
        {
            var placeholder1        = new Placeholder("area 1");
            var placeholder2        = new Placeholder("area 2");
            var widgetSpecification = new WidgetSpecification("widget");

            widgetSpecification.Insert(0, placeholder1);
            widgetSpecification.Insert(1, placeholder2);

            var area   = new Area("area 1");
            var widget = new Widget("widget", new[] { area });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            var instance = widget.Build(builder, new[] { 0 }, buildContext);

            var rendererFactory = MockRepository.GenerateStub <IRendererFactory>();

            this.viewHelper = MockRepository.GenerateStub <IViewHelper>();
            var multiRenderer = new MultiRenderer(rendererFactory);

            KolaConfigurationRegistry.RegisterRenderer(multiRenderer);

            this.result = instance.Render(multiRenderer);
        }
Example #5
0
        private PageInstance BuildPage(Template template, bool isPreview, IEnumerable <IContextItem> contextItems = null, string cacheControl = null)
        {
            if (isPreview)
            {
                template.ApplyAmendments(this.componentLibrary);
            }

            var renderingInstructions = isPreview
                ? RenderingInstructions.BuildForPreview()
                : RenderingInstructions.Build(cacheControl);

            var builder = new Builder(renderingInstructions, this.widgetSpecificationRepository.Find, this.componentLibrary);

            return(builder.Build(template, new BuildData(contextItems)));
        }