public void It_should_align_a_child_in_the_center() { _childBox.Width.Returns(50); var children = new GraphContainerHorizontal(); children.AddBox(A.GraphBoxStub().WithSize(50, 50).Build()); children.AddBox(A.GraphBoxStub().WithSize(50, 50).Build()); var wrapper = new GraphContainerVertical(); wrapper.AddBox(_childBox); wrapper.AddBox(children); _container.AddBox(wrapper); _container.CenterAlignChildren(); _childBox.Received(1).AddGlobalPosition(25, 0); }
public void On_nested_child_positions_on_added_boxes() { var boxA = new GraphBox(); boxA.SetSize(50, 50); var boxB = new GraphBox(); boxB.SetSize(50, 50); var nestedContainer = new GraphContainerHorizontal(); nestedContainer.AddBox(boxA); nestedContainer.AddBox(boxB); _container.SetGlobalPosition(50, 100); _container.AddBox(nestedContainer); Assert.AreEqual(100, boxB.GlobalPositionX); }
public void Root_should_push_down_the_next_node() { var tree = new GraphContainerVertical(); tree.SetGlobalPosition(300, 0); var nodeWrapper = new GraphContainerVertical(); var box = new GraphBox(); box.SetSize(50, 50); var childrenContainer = new GraphContainerHorizontal(); var childWrapper = new GraphContainerVertical(); var childBox = new GraphBox(); childBox.SetSize(50, 50); nodeWrapper.AddBox(box); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(0, box.GlobalPositionY); childWrapper.AddBox(childBox); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); childrenContainer.AddBox(childWrapper); Assert.AreEqual(50, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(0, childrenContainer.GlobalPositionY); nodeWrapper.AddBox(childrenContainer); Assert.AreEqual(100, nodeWrapper.Height); Assert.AreEqual(50, nodeWrapper.Width); Assert.AreEqual(50, childrenContainer.GlobalPositionY); tree.AddBox(nodeWrapper); Assert.AreEqual(0, nodeWrapper.LocalPositionY); Assert.AreEqual(0, nodeWrapper.GlobalPositionY); Assert.AreEqual(50, childrenContainer.GlobalPositionY); Assert.AreEqual(0, box.GlobalPositionY); }