Ejemplo n.º 1
0
        public void GenerateVisualTree_BlocksInContainerAreAddedAsIs()
        {
            var el = new MyElement {
                Children =
                {
                    new Wrap        {
                        Children =
                        {
                            new Div {
                                Name = "1"
                            },
                            new Div {
                                Name = "2"
                            },
                        }
                    }
                }
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().HaveCount(1);
            el.VisualChildren[0].Should().BeOfType <Wrap>();
            {
                IList <Element> children0 = el.VisualChildren[0].As <Wrap>().VisualChildren;
                children0.Should().HaveCount(2);

                children0[0].As <Div>().Name.Should().Be("1");
                children0[1].As <Div>().Name.Should().Be("2");
            }
        }
Ejemplo n.º 2
0
        public void GenerateVisualTree_NesteddInlinesAreGroupedIntoInlinesContainer()
        {
            var el = new MyElement {
                Children =
                {
                    new Span         {
                        Name     = "Foo",
                        Children =
                        {
                            new Span {
                                Name = "Bar"
                            },
                        },
                    },
                },
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().ContainSingle();
            el.VisualChildren[0].Should().BeOfType <InlineContainer>();
            {
                IList <Element> children0 = el.VisualChildren[0].As <InlineContainer>().VisualChildren;
                children0.Should().HaveCount(1);
                children0[0].As <Span>().Name.Should().Be("Foo");
                {
                    IList <Element> children00 = children0[0].As <Span>().VisualChildren;
                    children00.Should().HaveCount(1);
                    children00[0].As <Span>().Name.Should().Be("Bar");
                }
            }
        }
Ejemplo n.º 3
0
        public void GenerateVisualTree_BlocksAreGroupedIntoStack()
        {
            var el = new MyElement {
                Children =
                {
                    new Div {
                        Name = "1"
                    },
                    new Div {
                        Name = "2"
                    },
                }
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().HaveCount(1);
            el.VisualChildren[0].Should().BeOfType <Stack>();
            {
                IList <Element> children0 = el.VisualChildren[0].As <Stack>().VisualChildren;
                children0.Should().HaveCount(2);

                children0[0].As <Div>().Name.Should().Be("1");
                children0[1].As <Div>().Name.Should().Be("2");
            }
        }
Ejemplo n.º 4
0
        public void GenerateVisualTree_Empty()
        {
            var el = new MyElement();

            el.GenerateVisualTree();

            el.VisualChildren.Should().BeEmpty();
        }
Ejemplo n.º 5
0
        public void GenerateVisualTree_BlockAddedAsIs()
        {
            var el = new MyElement {
                Children =
                {
                    new Border(),
                }
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().HaveCount(1);
            el.VisualChildren[0].Should().BeOfType <Border>();
        }
Ejemplo n.º 6
0
        public void GenerateVisualTree_InlinesAreGroupedIntoInlinesContainer()
        {
            var el = new MyElement {
                Children =
                {
                    new Span("Foo"),
                    new Span("Bar"),
                }
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().ContainSingle();
            el.VisualChildren[0].Should().BeOfType <InlineContainer>();
            {
                IList <Element> children0 = el.VisualChildren[0].As <InlineContainer>().VisualChildren;
                children0.Should().HaveCount(2);

                children0[0].As <Span>().Text.Should().Be("Foo");
                children0[1].As <Span>().Text.Should().Be("Bar");
            }
        }
Ejemplo n.º 7
0
        public void GenerateVisualTree_InlinesSeparatedByBlockAreGroupedIntoSeparateInlinesContainers()
        {
            var el = new MyElement {
                Children =
                {
                    new Span("1"),
                    new Span("2"),
                    new Border(),
                    new Span("3"),
                    new Span("4"),
                }
            };

            el.GenerateVisualTree();

            el.VisualChildren.Should().HaveCount(1);
            el.VisualChildren[0].Should().BeOfType <Stack>();
            {
                IList <Element> children0 = el.VisualChildren[0].As <Stack>().VisualChildren;
                children0.Should().HaveCount(3);

                children0[0].Should().BeOfType <InlineContainer>();
                {
                    IList <Element> children01 = children0[0].As <InlineContainer>().VisualChildren;
                    children01.Should().HaveCount(2);
                    children01[0].As <Span>().Text.Should().Be("1");
                    children01[1].As <Span>().Text.Should().Be("2");
                }
                children0[1].Should().BeOfType <Border>();
                children0[2].Should().BeOfType <InlineContainer>();
                {
                    IList <Element> children02 = children0[2].As <InlineContainer>().VisualChildren;
                    children02.Should().HaveCount(2);
                    children02[0].As <Span>().Text.Should().Be("3");
                    children02[1].As <Span>().Text.Should().Be("4");
                }
            }
        }