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!"); }
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"); }
public void CanRenderForDisplayWithOneColumnContainerAndOnePart() { RootColumn root = new RootColumn(); root.Id = "root"; ColumnContainer target = new ColumnContainer(root); target.Id = "target"; target.Columns[0].Parts.Add(SamplePart1); target.Columns[1].Parts.Add(SamplePart4); root.Parts.Add(target); string expected = "<div class=\"cols\">"; expected += "<div class=\"grid_12\" >"; expected += "<div class=\"cols editable issortable spacerabove\"><div class=\"grid_6\" >"; expected += SamplePart1.RawHtml; expected += "</div>"; expected += "<div class=\"grid_6l\" >"; expected += SamplePart4.RawHtml; expected += "</div><div class=\"clearcol\"></div></div>"; expected += "</div>"; expected += "<div class=\"clearcol\"></div>"; expected += "</div>"; string actual; actual = root.RenderForDisplay(null, null); Assert.AreEqual(expected, actual); }
private void TestColumnSizes(IColumn parent, ColumnSize expected1, ColumnSize expected2) { ColumnContainer target = new ColumnContainer(parent); Assert.AreEqual(2, target.Columns.Count, "Container should start with two columns"); Assert.AreEqual(expected1, target.Columns[0].Size, "Column 1 was not the correct size for start of " + parent.ToString()); Assert.AreEqual(expected2, target.Columns[1].Size, "Column 2 was not the correct size for start of " + parent.ToString()); }
public void CanNotAddMoreColumnsThanSpaceAvailable() { RootColumn root = new RootColumn(); ColumnContainer target = new ColumnContainer(root); Assert.AreEqual(2, target.Columns.Count, "Container should have 2 column to start"); Assert.IsFalse(target.AddColumns(11), "Adding more columns than parent size should return false"); }
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 CanListColumnsOnCreateTest() { RootColumn root = new RootColumn(); ColumnContainer target = new ColumnContainer(root); List <Column> expected = new List <Column>(); List <Column> actual; actual = target.Columns; Assert.IsNotNull(actual, "List of columns should never be null"); Assert.AreEqual(2, actual.Count, "Column Count should always be 2 on new containers"); }
protected override void AddContainer(GameObject target) { ColumnContainer container = Undoable.AddComponent <ColumnContainer>(target); if (containerName == null) { target.name = "Column"; } container.padding = padding; container.spacing = spacing; }
public void CanAddColumnToContainer() { RootColumn root = new RootColumn(); ColumnContainer target = new ColumnContainer(root); Assert.AreEqual(2, target.Columns.Count, "Container should start with two columns"); Assert.IsTrue(target.AddColumns(1), "Should return true when adding column"); Assert.AreEqual(3, target.Columns.Count, "Column Cound should be 3"); Assert.AreEqual(ColumnSize.Size4, target.Columns[0].Size, "First column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[1].Size, "Second column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[2].Size, "Third column number should be size 4"); }
private TableContainer CreateCharacterTableGUI(VisualElement root, out ColumnContainer columnContainer) { var tableContainer = new TableContainer(); root.Add(tableContainer); tableContainer.Add(new Label("Characters")); columnContainer = new ColumnContainer(); tableContainer.Add(columnContainer); return(tableContainer); }
public void CanSetNumberOfColumns() { ColumnContainer target = new ColumnContainer(new RootColumn()); Assert.IsTrue(target.SetNumberOfColumns(3), "Should be able to set three columns"); Assert.AreEqual(3, target.Columns.Count, "Column Count should be three"); ColumnContainer target2 = new ColumnContainer(new RootColumn()); Assert.IsTrue(target2.SetNumberOfColumns(7), "Should be able to set seven columns"); Assert.AreEqual(7, target2.Columns.Count, "Column Count should be sevent"); }
public void CanNotSetColumnsToMoreThanParentSize() { ColumnContainer target = new ColumnContainer(new RootColumn()); Assert.IsFalse(target.SetNumberOfColumns(13), "Should not be able to set columns to more than size 12"); ColumnContainer target2 = new ColumnContainer(new Column() { Size = ColumnSize.Size5 }); Assert.IsFalse(target2.SetNumberOfColumns(6), "Should not be able to set columns to more than size 5"); }
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); }
public void CanFailToResizeColumnWhenBiggerThanMax() { RootColumn root = new RootColumn(); ColumnContainer target = new ColumnContainer(root); Assert.AreEqual(2, target.Columns.Count, "Container should start with two columns"); Assert.IsTrue(target.AddColumns(1), "Should return true when adding column"); Assert.AreEqual(3, target.Columns.Count, "Column Cound should be 3"); Assert.AreEqual(ColumnSize.Size4, target.Columns[0].Size, "First column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[1].Size, "Second column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[2].Size, "Third column number should be size 4"); Assert.IsFalse(target.ResizeColumn(0, ColumnSize.Size11), "Column should not resize to size 11"); }
// Use this for initialization public void GenerateMap(int columns, int rows, int minMagnitude, int ballAmount, float ballSpeed, float playerSpeed) { _balls = new List <Ball>(); _list = new ColumnContainer[columns]; for (int i = 0; i < columns; i++) { _list[i] = new ColumnContainer(); } for (int i = 0; i < ballAmount; i++) { _balls.Add(Instantiate(_ballPrefab).GetComponent <Ball>()); _balls[i].speed = ballSpeed; } _player = Instantiate(_playerPrefab).GetComponent <PlayerMove>(); _player.speed = playerSpeed; float[] rots = Arc.ArcRotations(columns, -1.0f, 0.0f, false); Vector2[] locs; for (int i = 0; i < rows; i++) { locs = Arc.ArcLocations(columns, -1.0f, 0.0f, i + minMagnitude, false); for (int j = 0; j < columns; j++) { _list[j].Add(Instantiate(_brickPrefab)); _list[j][i].transform.Rotate(new Vector3(0, 0, -rots[j]) * 360); _list[j][i].transform.position = locs[j]; Brick brick = _list[j][i].GetComponent <Brick>(); brick.myContainer = _list[j]; brick.Reshape(columns, i + minMagnitude); brick.breakable = true; } } locs = Arc.ArcLocations(columns, -1.0f, 0.0f, rows + minMagnitude, false); for (int j = 0; j < columns; j++) { _list[j].Add(Instantiate(_brickPrefab)); _list[j][rows].transform.Rotate(new Vector3(0, 0, -rots[j]) * 360); _list[j][rows].transform.position = locs[j]; Brick brick = _list[j][rows].GetComponent <Brick>(); brick.myContainer = _list[j]; brick.Reshape(columns, rows + minMagnitude); brick.breakable = false; } }
public void CanResizeColumnsUsingShorthand() { RootColumn root = new RootColumn(); ColumnContainer target = new ColumnContainer(root); target.SetNumberOfColumns(3); Assert.AreEqual(3, target.Columns.Count, "Column Cound should be 3"); Assert.AreEqual(ColumnSize.Size4, target.Columns[0].Size, "First column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[1].Size, "Second column number should be size 4"); Assert.AreEqual(ColumnSize.Size4, target.Columns[2].Size, "Third column number should be size 4"); Assert.IsTrue(target.SetColumnSizes("10,1,1"), "Column set size should be true"); Assert.AreEqual(ColumnSize.Size10, target.Columns[0].Size, "First column number should be size 10"); Assert.AreEqual(ColumnSize.Size1, target.Columns[1].Size, "Second column number should be size 1"); Assert.AreEqual(ColumnSize.Size1, target.Columns[2].Size, "Third column number should be size 1"); }
private TableContainer CreateCommandTableGUI(VisualElement root, ICommandList onStart, ICommandList onEnd) { var tableContainer = new TableContainer(); root.Add(tableContainer); tableContainer.Add(new Label("Commands")); var columnContainer = new ColumnContainer(); tableContainer.Add(columnContainer); CreateCommandList <OnStartColumnElement>(columnContainer, "On Start", onStart); CreateCommandList <OnEndColumnElement>(columnContainer, "On End", onEnd); return(tableContainer); }
public void CanResizeColumnsUsingShorthand2() { ColumnContainer target = new ColumnContainer(new Column() { Size = ColumnSize.Size9 }); target.SetNumberOfColumns(5); Assert.AreEqual(5, target.Columns.Count, "Column Cound should be 5"); Assert.IsTrue(target.SetColumnSizes("4w,2w,1,1,1"), "Column set size should be true"); Assert.AreEqual(ColumnSize.Size4, target.Columns[0].Size, "First column number should be size 4"); Assert.IsTrue(target.Columns[0].NoGutter, "First Column should have no gutter turned on"); Assert.AreEqual(ColumnSize.Size2, target.Columns[1].Size, "Second column number should be size 2"); Assert.IsTrue(target.Columns[1].NoGutter, "Second Column should have no gutter turned on"); Assert.AreEqual(ColumnSize.Size1, target.Columns[2].Size, "Third column number should be size 1"); Assert.AreEqual(ColumnSize.Size1, target.Columns[3].Size, "Fourth column number should be size 1"); Assert.AreEqual(ColumnSize.Size1, target.Columns[4].Size, "Fifth column number should be size 1"); }
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"); }
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"); }
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); }
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><h1>hello, world!</h1></rawhtml></part>"; source += "<part><id>test3</id><typecode>htmlpart</typecode><rawhtml><p>Lorem Ipsum</p></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); }
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><h1>hello, world!</h1></rawhtml></part>"; expected += "<part><id>test3</id><typecode>htmlpart</typecode><rawhtml><p>Lorem Ipsum</p></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 CanNotSetColumnsToOne() { ColumnContainer target = new ColumnContainer(new RootColumn()); Assert.IsFalse(target.SetNumberOfColumns(1), "Should not be able to set columns to one"); }