public void HorizontalControls() { var controlList = createfilledControlList(); controlList[0].DrawArea = new Rectangle(-2.5f, 0, 1, 1); controlList[1].DrawArea = new Rectangle(-0.5f, 0, 1, 1); controlList[2].DrawArea = new Rectangle(2.5f, 0, 1, 1); var anchoredControl = new Button(Rectangle.One); ControlAnchorer.AnchorSelectedControls(anchoredControl, controlList); Assert.AreEqual(new Vector2D(-2.5f, 0), controlList[0].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(-0.5f, 0), controlList[1].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(2.5f, 0), controlList[2].DrawArea.TopLeft); anchoredControl.DrawArea = new Rectangle(0.5f, 0, 1, 1); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(new Vector2D(-2, 0), controlList[0].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(0, 0), controlList[1].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(3f, 0), controlList[2].DrawArea.TopLeft); }
public void AchorControlsVerticalControls() { var controlList = createfilledControlList(); controlList[0].DrawArea = new Rectangle(0, -1.5f, 1, 1); controlList[1].DrawArea = new Rectangle(0, -0.5f, 1, 1); controlList[2].DrawArea = new Rectangle(0, 1.5f, 1, 1); var anchoredControl = new Button(Rectangle.One); ControlAnchorer.AnchorSelectedControls(anchoredControl, controlList); Assert.AreEqual(new Vector2D(0, -1.5f), controlList[0].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(0, -0.5f), controlList[1].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(0, 1.5f), controlList[2].DrawArea.TopLeft); anchoredControl.DrawArea = new Rectangle(0, 0.5f, 1, 1); AdvanceTimeAndUpdateEntities(); Assert.AreEqual(new Vector2D(0, -1), controlList[0].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(0, 0), controlList[1].DrawArea.TopLeft); Assert.AreEqual(new Vector2D(0, 2f), controlList[2].DrawArea.TopLeft); }