예제 #1
0
 public void CanAddContentPart()
 {
     RootColumn root = new RootColumn();
     ColumnContainer target = new ColumnContainer(root);
     IContentPart part1 = new Html() { Id = "1234", RawHtml = "Hello, World" };            
     bool expected = true; 
     bool actual;
     actual = target.Columns[0].AddPart(part1);
     Assert.AreEqual(expected, actual);
 }
예제 #2
0
        public static IContentPart Instantiate(string id, string typecode, IColumn parentColumn)
        {
            switch (typecode.Trim().ToLowerInvariant())
            {
                case "columncontainer":
                    ColumnContainer container = new ColumnContainer(parentColumn);
                    container.Id = id;
                    return container;                    
                case "column":
                    Column col = new Column();
                    col.Id = id;                    
                    return col;                    
                case "htmlpart":
                    Html htmlpart = new Html();
                    htmlpart.Id = id;
                    return htmlpart;
                case "image":
                    Image img = new Image();
                    return img;
            }

            return null;
        }
예제 #3
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;
        }
예제 #4
0
        public void CanRemoveSingleContentPart()
        {
            RootColumn root = new RootColumn();
            ColumnContainer target = new ColumnContainer(root);

            Html part1 = new Html() { Id = "1234", RawHtml = "Hello, World" };
            
            target.Columns[0].AddPart(part1);
            
            bool expected = true; 
            bool actual;
            actual = target.Columns[0].RemovePart(part1.Id);
            Assert.AreEqual(expected, actual);

            List<IContentPart> partsAfter = target.Columns[0].Parts;
            Assert.AreEqual(0, partsAfter.Count, "Part count should be zero after remove");
        }
예제 #5
0
        public void CanListParts()
        {
            RootColumn root = new RootColumn();
            ColumnContainer target = new ColumnContainer(root);

            Html part1 = new Html() { Id = "1234", RawHtml = "Hello, World" };
            
            List<IContentPart> expected = new List<IContentPart>() { part1 };
            List<IContentPart> actual;
            target.Columns[0].AddPart(part1);
            actual = target.Columns[0].Parts;
            Assert.AreEqual(1, actual.Count, "Count should be one");
            Assert.AreEqual(expected[0].Id, actual[0].Id, "part id value didn't match as expected");            
        }
예제 #6
0
        public void CanFailWhenRemovingContentPart()
        {
            RootColumn root = new RootColumn();
            ColumnContainer target = new ColumnContainer(root);

            Html part1 = new Html() { Id = "1234", RawHtml = "Hello, World" };
            Html part2 = new Html() { Id = "5678", RawHtml = "Hello, World 2" };
            target.Columns[0].AddPart(part1);
            target.Columns[0].AddPart(part2);
            
            string nonExistingPartId = "56789";                        
            bool expected = false;
            bool actual;
            actual = target.Columns[0].RemovePart(nonExistingPartId);
            Assert.AreEqual(expected, actual);

            List<IContentPart> partsAfter = target.Columns[0].Parts;
            Assert.AreEqual(2, partsAfter.Count, "Part count should be two after failed remove");           
        }
예제 #7
0
        public void CanRemoveContentPartFromList()
        {
            RootColumn root = new RootColumn();
            ColumnContainer target = new ColumnContainer(root);

            Html part1 = new Html() { Id = "1234", RawHtml = "Hello, World" };
            Html part2 = new Html() { Id = "5678", RawHtml = "Hello, World 2" };

            target.Columns[0].AddPart(part1);
            target.Columns[0].AddPart(part2);
            
            bool expected = true;
            bool actual;
            
            actual = target.Columns[0].RemovePart(part1.Id);
            Assert.AreEqual(expected, actual);

            List<IContentPart> partsAfter = target.Columns[0].Parts;
            Assert.AreEqual(1, partsAfter.Count, "Part count should be one after remove");
            Assert.AreEqual(part2.Id, partsAfter[0].Id, "Wrong part was removed!");
        }