public void TopToBottomContainerAppliesExpectedMarginToToggleView() { TestContext.CurrentContext.SetCompatibleWorkingDirectory(); int marginSize = 40; int dimensions = 300; GuiWidget outerContainer = new GuiWidget(dimensions, dimensions); FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) { HAnchor = HAnchor.ParentLeftRight, VAnchor = VAnchor.ParentBottomTop, }; outerContainer.AddChild(topToBottomContainer); CheckBox toggleBox = new CheckBox("test"); toggleBox.HAnchor = HAnchor.ParentLeftRight; toggleBox.VAnchor = VAnchor.ParentBottomTop; toggleBox.Margin = new BorderDouble(marginSize); toggleBox.BackgroundColor = RGBA_Bytes.Red; toggleBox.DebugShowBounds = true; topToBottomContainer.AddChild(toggleBox); topToBottomContainer.AnchorAll(); topToBottomContainer.PerformLayout(); outerContainer.DoubleBuffer = true; outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White); outerContainer.OnDraw(outerContainer.NewGraphics2D()); // For troubleshooting or visual validation OutputImages(outerContainer, outerContainer); var bounds = toggleBox.BoundsRelativeToParent; Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect"); Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect"); Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect"); Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect"); }