Beispiel #1
0
        public RootColumn GetSimpleSample()
        {
            RootColumn root = new RootColumn();



            // Sidebar + Main Column
            ColumnContainer col1 = new ColumnContainer(root);

            col1.SetColumns("3,9");
            root.Parts.Add(col1);

            col1.Columns[0].AddPart(new Html());
            col1.Columns[1].AddPart(new Html()
            {
                RawHtml = "<h1>Heading</h1>"
            });
            col1.Columns[1].AddPart(new Html());
            col1.Columns[1].AddPart(new Html()
            {
                RawHtml = "<h2>Sub Heading</h2>"
            });
            col1.Columns[1].AddPart(new Html());

            ColumnContainer col2 = new ColumnContainer(col1.Columns[1]);

            col2.SetColumns("2,5,2");
            col2.Columns[0].AddPart(new Html()
            {
                RawHtml = "<p>Left Side</p>"
            });
            col2.Columns[1].AddPart(new Html());
            col2.Columns[2].AddPart(new Html()
            {
                RawHtml = "<ul><li>One</li><li>Two</li><li>Three</li></ul>"
            });
            col1.Columns[1].AddPart(col2);

            ColumnContainer small = new ColumnContainer(col2.Columns[2]);

            small.SetColumns("1,1");
            small.Columns[0].AddPart(new Html()
            {
                RawHtml = "Small text goes here"
            });
            small.Columns[1].AddPart(new Html()
            {
                RawHtml = "More small text!"
            });
            col2.Columns[2].AddPart(small);

            root.Parts.Add(new Html());

            return(root);
        }
        public void CanSerializeRootColumnToXmlString()
        {
            RootColumn      target = new RootColumn();
            ColumnContainer cols   = new ColumnContainer(target);

            target.AddPart(cols);
            cols.SetColumns("2,10");
            cols.Columns[0].AddPart(new Html()
            {
                Id = "test1", RawHtml = "sidebar"
            });
            cols.Columns[1].AddPart(new Html()
            {
                Id = "test2", RawHtml = "<h1>hello, world!</h1>"
            });
            cols.Columns[1].AddPart(new Html()
            {
                Id = "test3", RawHtml = "<p>Lorem Ipsum</p>"
            });

            ColumnContainer cols2 = new ColumnContainer(cols.Columns[1]);

            cols2.SetColumns("4w,6");
            cols2.Columns[0].AddPart(new Html()
            {
                Id = "test4", RawHtml = "inside"
            });
            cols2.Columns[1].AddPart(new Html()
            {
                Id = "test5", RawHtml = "outside"
            });
            cols.Columns[1].AddPart(cols2);


            string expected = "<rootcolumn>";

            expected += "<id>" + target.Id + "</id>";
            expected += "<parts>";

            expected += "<part><id>" + cols.Id + "</id><typecode>columncontainer</typecode>";
            expected += "<spacerabove>true</spacerabove>";
            expected += "<columns>";

            expected += "<part><id>" + cols.Columns[0].Id + "</id><typecode>column</typecode>";
            expected += "<size>Size2</size><nogutter>false</nogutter>";
            expected += "<parts>";
            expected += "<part><id>test1</id><typecode>htmlpart</typecode><rawhtml>sidebar</rawhtml></part>";
            expected += "</parts>";
            expected += "</part>";

            expected += "<part><id>" + cols.Columns[1].Id + "</id><typecode>column</typecode>";
            expected += "<size>Size10</size><nogutter>false</nogutter>";
            expected += "<parts>";
            expected += "<part><id>test2</id><typecode>htmlpart</typecode><rawhtml>&lt;h1&gt;hello, world!&lt;/h1&gt;</rawhtml></part>";
            expected += "<part><id>test3</id><typecode>htmlpart</typecode><rawhtml>&lt;p&gt;Lorem Ipsum&lt;/p&gt;</rawhtml></part>";
            expected += "<part><id>" + cols2.Id + "</id><typecode>columncontainer</typecode>";
            expected += "<spacerabove>true</spacerabove>";
            expected += "<columns>";

            expected += "<part><id>" + cols2.Columns[0].Id + "</id><typecode>column</typecode>";
            expected += "<size>Size4</size><nogutter>true</nogutter>";
            expected += "<parts>";
            expected += "<part><id>test4</id><typecode>htmlpart</typecode><rawhtml>inside</rawhtml></part>";
            expected += "</parts>";
            expected += "</part>";
            expected += "<part><id>" + cols2.Columns[1].Id + "</id><typecode>column</typecode>";
            expected += "<size>Size6</size><nogutter>false</nogutter>";
            expected += "<parts>";
            expected += "<part><id>test5</id><typecode>htmlpart</typecode><rawhtml>outside</rawhtml></part>";
            expected += "</parts>";
            expected += "</part>";

            expected += "</columns>";
            expected += "</part>";

            expected += "</parts>";
            expected += "</part>";

            expected += "</columns>";
            expected += "</part>";

            expected += "</parts>";
            expected += "</rootcolumn>";

            string actual;

            actual = target.SerializeToString();
            Assert.AreEqual(expected, actual);
        }
        public void CanDeserializeRootColumnFromXmlString()
        {
            string source = "<rootcolumn>";

            source += "<id>rootcol</id>";
            source += "<parts>";
            source += "<part><id>col1</id><typecode>columncontainer</typecode>";
            source += "<spacerabove>true</spacerabove>";
            source += "<columns>";
            source += "<part><id>col1a</id><typecode>column</typecode>";
            source += "<size>Size2</size><nogutter>false</nogutter>";
            source += "<parts>";
            source += "<part><id>test1</id><typecode>htmlpart</typecode><rawhtml>sidebar</rawhtml></part>";
            source += "</parts>";
            source += "</part>";
            source += "<part><id>col1b</id><typecode>column</typecode>";
            source += "<size>Size10</size><nogutter>false</nogutter>";
            source += "<parts>";
            source += "<part><id>test2</id><typecode>htmlpart</typecode><rawhtml>&lt;h1&gt;hello, world!&lt;/h1&gt;</rawhtml></part>";
            source += "<part><id>test3</id><typecode>htmlpart</typecode><rawhtml>&lt;p&gt;Lorem Ipsum&lt;/p&gt;</rawhtml></part>";
            source += "<part><id>col2</id><typecode>columncontainer</typecode>";
            source += "<spacerabove>true</spacerabove>";
            source += "<columns>";
            source += "<part><id>col2a</id><typecode>column</typecode>";
            source += "<size>Size4</size><nogutter>true</nogutter>";
            source += "<parts>";
            source += "<part><id>test4</id><typecode>htmlpart</typecode><rawhtml>inside</rawhtml></part>";
            source += "</parts>";
            source += "</part>";
            source += "<part><id>col2b</id><typecode>column</typecode>";
            source += "<size>Size6</size><nogutter>false</nogutter>";
            source += "<parts>";
            source += "<part><id>test5</id><typecode>htmlpart</typecode><rawhtml>outside</rawhtml></part>";
            source += "</parts>";
            source += "</part>";
            source += "</columns>";
            source += "</part>";
            source += "</parts>";
            source += "</part>";
            source += "</columns>";
            source += "</part>";
            source += "</parts>";
            source += "</rootcolumn>";



            RootColumn expected = new RootColumn();

            expected.Id = "rootcol";
            ColumnContainer cols = new ColumnContainer(expected);

            cols.Id = "col1";
            expected.AddPart(cols);
            cols.SetColumns("2,10");
            cols.Columns[0].Id = "col1a";
            cols.Columns[1].Id = "col1b";
            cols.Columns[0].AddPart(new Html()
            {
                Id = "test1", RawHtml = "sidebar"
            });
            cols.Columns[1].AddPart(new Html()
            {
                Id = "test2", RawHtml = "<h1>hello, world!</h1>"
            });
            cols.Columns[1].AddPart(new Html()
            {
                Id = "test3", RawHtml = "<p>Lorem Ipsum</p>"
            });

            ColumnContainer cols2 = new ColumnContainer(cols.Columns[1]);

            cols2.Id = "col2";
            cols2.SetColumns("4w,6");
            cols2.Columns[0].Id = "col2a";
            cols2.Columns[1].Id = "col2b";
            cols2.Columns[0].AddPart(new Html()
            {
                Id = "test4", RawHtml = "inside"
            });
            cols2.Columns[1].AddPart(new Html()
            {
                Id = "test5", RawHtml = "outside"
            });
            cols.Columns[1].AddPart(cols2);


            RootColumn actual = new RootColumn();

            actual.DeserializeFromXml(source);

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.MinimumSize(), actual.MinimumSize());
            Assert.AreEqual(expected.NoGutter, actual.NoGutter);
            Assert.AreEqual(1, actual.Parts.Count);

            ColumnContainer actualCols = (ColumnContainer)actual.Parts[0];

            Assert.IsNotNull(actualCols);

            Assert.AreEqual(cols.Id, actualCols.Id);
            Assert.AreEqual(cols.Columns.Count, actualCols.Columns.Count);
            Assert.AreEqual(cols.MinimumSize(), actualCols.MinimumSize());

            // Column 1
            Assert.AreEqual(cols.Columns[0].Id, actualCols.Columns[0].Id);
            Assert.AreEqual(cols.Columns[0].NoGutter, actualCols.Columns[0].NoGutter);
            Assert.AreEqual(cols.Columns[0].Parts.Count, actualCols.Columns[0].Parts.Count);
            Assert.AreEqual(cols.Columns[0].Size, actualCols.Columns[0].Size);
            // Part 1 in Column 1
            Html test1 = (Html)actualCols.Columns[0].Parts[0];

            Assert.IsNotNull(test1);
            Assert.AreEqual("test1", test1.Id);
            Assert.AreEqual("sidebar", test1.RawHtml);


            // Column 2
            Assert.AreEqual(cols.Columns[1].Id, actualCols.Columns[1].Id);
            Assert.AreEqual(cols.Columns[1].NoGutter, actualCols.Columns[1].NoGutter);
            Assert.AreEqual(cols.Columns[1].Parts.Count, actualCols.Columns[1].Parts.Count);
            Assert.AreEqual(cols.Columns[1].Size, actualCols.Columns[1].Size);

            // Part 1 in Column 2
            Html test2 = (Html)actualCols.Columns[1].Parts[0];

            Assert.IsNotNull(test2);
            Assert.AreEqual("test2", test2.Id);
            Assert.AreEqual("<h1>hello, world!</h1>", test2.RawHtml);

            // Part 2 in Column 2
            Html test3 = (Html)actualCols.Columns[1].Parts[1];

            Assert.IsNotNull(test3);
            Assert.AreEqual("test3", test3.Id);
            Assert.AreEqual("<p>Lorem Ipsum</p>", test3.RawHtml);

            // ColumnContainer 2 inside column 2
            ColumnContainer actualCols2 = (ColumnContainer)actualCols.Columns[1].Parts[2];

            Assert.IsNotNull(actualCols2);
            Assert.AreEqual(cols2.Columns.Count, actualCols2.Columns.Count);
            Assert.AreEqual(cols2.Id, actualCols2.Id);
            Assert.AreEqual(cols2.MinimumSize(), actualCols2.MinimumSize());

            // ColumnContainer2 column 1
            Assert.AreEqual(cols2.Columns[0].Id, actualCols2.Columns[0].Id);
            Assert.AreEqual(cols2.Columns[0].NoGutter, actualCols2.Columns[0].NoGutter);
            Assert.AreEqual(cols2.Columns[0].Parts.Count, actualCols2.Columns[0].Parts.Count);
            Assert.AreEqual(cols2.Columns[0].Size, actualCols2.Columns[0].Size);
            // ColumnContainer2 Part 1 in Column 1
            Html test4 = (Html)actualCols2.Columns[0].Parts[0];

            Assert.IsNotNull(test4);
            Assert.AreEqual("test4", test4.Id);
            Assert.AreEqual("inside", test4.RawHtml);

            // ColumnContainer2 column 2
            Assert.AreEqual(cols2.Columns[1].Id, actualCols2.Columns[1].Id);
            Assert.AreEqual(cols2.Columns[1].NoGutter, actualCols2.Columns[1].NoGutter);
            Assert.AreEqual(cols2.Columns[1].Parts.Count, actualCols2.Columns[1].Parts.Count);
            Assert.AreEqual(cols2.Columns[1].Size, actualCols2.Columns[1].Size);

            // ColumnContainer2 Part 1 in Column 2
            Html test5 = (Html)actualCols2.Columns[1].Parts[0];

            Assert.IsNotNull(test5);
            Assert.AreEqual("test5", test5.Id);
            Assert.AreEqual("outside", test5.RawHtml);

            // Make sure everything renders as expected
            string expectedRender = expected.RenderForDisplay(new MerchantTribeApplication(new RequestContext(), true), null);
            string actualRender   = actual.RenderForDisplay(new MerchantTribeApplication(new RequestContext(), true), null);

            Assert.AreEqual(expectedRender, actualRender);
        }
Beispiel #4
0
        public RootColumn GetSampleContent()
        {
            RootColumn root = new RootColumn();

            Html part1 = new Html()
            {
                RawHtml = "Wide Area Here - Col 12"
            };

            root.Parts.Add(part1);

            // Sidebar + Main Column
            ColumnContainer col1 = new ColumnContainer(root);

            col1.SetColumns("3w,9");
            root.Parts.Add(col1);

            // First 3 in sidebar
            ColumnContainer colside1 = new ColumnContainer(col1.Columns[0]);

            colside1.SetColumns("1,1,1w");
            colside1.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "1"
            });
            colside1.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "1"
            });
            colside1.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "1w"
            });
            col1.Columns[0].Parts.Add(colside1);

            // Second group in side
            ColumnContainer colside2 = new ColumnContainer(col1.Columns[0]);

            colside2.SetColumns("2w,1w");
            colside2.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "2w"
            });
            colside2.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "1w"
            });
            col1.Columns[0].Parts.Add(colside2);

            // Third group in side
            ColumnContainer colside3 = new ColumnContainer(col1.Columns[0]);

            colside3.SetColumns("1,2");
            colside3.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "1"
            });
            colside3.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "2l"
            });
            col1.Columns[0].Parts.Add(colside3);

            // Html in bottom of sidebar
            col1.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "This is some content that will span the entire sidebar column and should be 3 columns wide."
            });



            // Start Grid 9 Area
            col1.Columns[1].AddPart(new Html()
            {
                RawHtml = "Grid 9 - should be bumped up against wide column"
            });


            // 4 column in 9
            ColumnContainer nine1 = new ColumnContainer(col1.Columns[1]);

            nine1.SetColumns("2,2,2,3");
            nine1.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "2"
            });
            nine1.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "2"
            });
            nine1.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "2"
            });
            nine1.Columns[3].Parts.Add(new Html()
            {
                RawHtml = "3l"
            });
            col1.Columns[1].Parts.Add(nine1);

            col1.Columns[1].AddPart(new Html()
            {
                RawHtml = "And Another Section"
            });


            // 5 column in 9
            ColumnContainer nine2 = new ColumnContainer(col1.Columns[1]);

            nine2.SetColumns("4,2,1,1,1");
            nine2.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "4"
            });
            nine2.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "2"
            });
            nine2.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "1"
            });
            nine2.Columns[3].Parts.Add(new Html()
            {
                RawHtml = "1"
            });
            nine2.Columns[4].Parts.Add(new Html()
            {
                RawHtml = "1l"
            });
            col1.Columns[1].Parts.Add(nine2);

            col1.Columns[1].AddPart(new Html()
            {
                RawHtml = "And Same Section (no gaps)"
            });

            // 5wide column in 9
            ColumnContainer nine3 = new ColumnContainer(col1.Columns[1]);

            nine3.SetColumns("4w,2w,1w,1w,1w");
            nine3.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "4w"
            });
            nine3.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "2w"
            });
            nine3.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "1w"
            });
            nine3.Columns[3].Parts.Add(new Html()
            {
                RawHtml = "1w"
            });
            nine3.Columns[4].Parts.Add(new Html()
            {
                RawHtml = "1l"
            });
            col1.Columns[1].Parts.Add(nine3);

            // 12 columns
            root.AddPart(new Html()
            {
                RawHtml = "After Others"
            });
            ColumnContainer r1 = new ColumnContainer(root);

            r1.SetColumns("1,1,1,1,1,1,1,1,1,1,1,1");
            for (int i = 0; i < 12; i++)
            {
                r1.Columns[i].Parts.Add(new Html()
                {
                    RawHtml = "1"
                });
            }
            root.AddPart(r1);


            // 12 columns
            root.AddPart(new Html()
            {
                RawHtml = "Smallest Columns (no gaps)"
            });
            ColumnContainer r2 = new ColumnContainer(root);

            r2.SetColumns("1w,1w,1w,1w,1w,1w,1w,1w,1w,1w,1w,1w");
            for (int i = 0; i < 12; i++)
            {
                r2.Columns[i].Parts.Add(new Html()
                {
                    RawHtml = "1"
                });
            }
            root.AddPart(r2);


            // 2 even columns
            root.AddPart(new Html()
            {
                RawHtml = "2 even columns"
            });
            ColumnContainer r3 = new ColumnContainer(root);

            r3.SetColumns("6,6");
            r3.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "6"
            });
            r3.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "6l"
            });
            root.AddPart(r3);

            // 3 even columns
            root.AddPart(new Html()
            {
                RawHtml = "3 even columns"
            });
            ColumnContainer r4 = new ColumnContainer(root);

            r4.SetColumns("4,4,4");
            r4.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "4"
            });
            r4.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "4"
            });
            r4.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "4l"
            });
            root.AddPart(r4);


            // 4 even columns
            root.AddPart(new Html()
            {
                RawHtml = "4 even columns"
            });
            ColumnContainer r4e = new ColumnContainer(root);

            r4e.SetColumns("3,3,3,3");
            r4e.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "3"
            });
            r4e.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "3"
            });
            r4e.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "3"
            });
            r4e.Columns[3].Parts.Add(new Html()
            {
                RawHtml = "3l"
            });
            root.AddPart(r4e);


            // 2 sides + middle
            root.AddPart(new Html()
            {
                RawHtml = "2 sides + middle"
            });
            ColumnContainer r5 = new ColumnContainer(root);

            r5.SetColumns("2,8,2");
            r5.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "2"
            });
            r5.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "8"
            });
            r5.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "2l"
            });
            root.AddPart(r5);

            // 2 sides wide + middle
            root.AddPart(new Html()
            {
                RawHtml = "2 sides wide + middle"
            });
            ColumnContainer r6 = new ColumnContainer(root);

            r6.SetColumns("3,6,3");
            r6.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "3"
            });
            r6.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "6"
            });
            r6.Columns[2].Parts.Add(new Html()
            {
                RawHtml = "3l"
            });
            root.AddPart(r6);

            // Side Left
            root.AddPart(new Html()
            {
                RawHtml = "Side Left"
            });
            ColumnContainer sl = new ColumnContainer(root);

            sl.SetColumns("3,9");
            sl.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "3"
            });
            sl.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "9l"
            });
            root.AddPart(sl);

            // Side Right
            root.AddPart(new Html()
            {
                RawHtml = "Side Right"
            });
            ColumnContainer sr = new ColumnContainer(root);

            sr.SetColumns("9,3");
            sr.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "9"
            });
            sr.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "3l"
            });
            root.AddPart(sr);


            // Off Balance Right
            root.AddPart(new Html()
            {
                RawHtml = "Off Balance Right"
            });
            ColumnContainer sr2 = new ColumnContainer(root);

            sr2.SetColumns("5,7");
            sr2.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "5"
            });
            sr2.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "7l"
            });
            root.AddPart(sr2);


            // Off Balance Left
            root.AddPart(new Html()
            {
                RawHtml = "Off Balance Left"
            });
            ColumnContainer sl2 = new ColumnContainer(root);

            sl2.SetColumns("7,5");
            sl2.Columns[0].Parts.Add(new Html()
            {
                RawHtml = "7"
            });
            sl2.Columns[1].Parts.Add(new Html()
            {
                RawHtml = "5l"
            });
            root.AddPart(sl2);

            root.AddPart(new Html()
            {
                RawHtml = "<p>End of Samples</p>"
            });


            return(root);
        }