public void PositionateLeftRelativeOnCornerEdge() { var edge = new OnCornerEdge(); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); edge = new OnCornerEdge(VerticalPlace.TOP); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.Y + edge.Left.Height / 2, edge.Right.Position.Value.Y); edge = new OnCornerEdge(VerticalPlace.BOTTOM); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.Y + edge.Left.Height - (edge.Left.Height / 2), edge.Right.Position.Value.Y + edge.Right.Height); edge = new OnCornerEdge(HorizontalPlace.LEFT); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width / 2, edge.Right.Position.Value.X); edge = new OnCornerEdge(HorizontalPlace.RIGHT); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width - edge.Left.Width / 2, edge.Right.Position.Value.X + edge.Right.Width); edge = new OnCornerEdge(HorizontalPlace.RIGHT, VerticalPlace.TOP); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width - edge.Left.Width / 2, edge.Right.Position.Value.X + edge.Right.Width); Assert.AreEqual(edge.Left.Position.Value.Y + (edge.Left.Height / 2), edge.Right.Position.Value.Y); edge = new OnCornerEdge(HorizontalPlace.LEFT, VerticalPlace.TOP); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width / 2, edge.Right.Position.Value.X); Assert.AreEqual(edge.Left.Position.Value.Y + (edge.Left.Height / 2), edge.Right.Position.Value.Y); edge = new OnCornerEdge(HorizontalPlace.RIGHT, VerticalPlace.BOTTOM); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width - edge.Left.Width / 2, edge.Right.Position.Value.X + edge.Right.Width); Assert.AreEqual(edge.Left.Position.Value.Y + edge.Left.Height - (edge.Left.Height / 2), edge.Right.Position.Value.Y + edge.Right.Height); edge = new OnCornerEdge(HorizontalPlace.LEFT, VerticalPlace.BOTTOM); edge.Add(this.Left, this.Right); this.Right.Position = new Vector2(WIDTH / 2, HEIGHT / 2); AssertEdgeInside(edge, 1); Assert.AreEqual(edge.Left.Position.Value.X + edge.Left.Width / 2, edge.Right.Position.Value.X); Assert.AreEqual(edge.Left.Position.Value.Y + edge.Left.Height - (edge.Left.Height / 2), edge.Right.Position.Value.Y + edge.Right.Height); }
private void AssertCornerEdge(IPositionateEdge edge, HorizontalPlace horizontal) { HorizontalPlace edgeHorizontal; if (edge is InCornerEdge cornerEdge) { edgeHorizontal = cornerEdge.Horizontal; } else { OnCornerEdge onCornerEdge = (OnCornerEdge)edge; edgeHorizontal = onCornerEdge.Horizontal; } Assert.AreEqual(edgeHorizontal, horizontal); }
private void AssertCornerEdge(IPositionateEdge edge, VerticalPlace vertical) { VerticalPlace edgeVertical; if (edge is InCornerEdge cornerEdge) { edgeVertical = cornerEdge.Vertical; } else { OnCornerEdge onCornerEdge = (OnCornerEdge)edge; edgeVertical = onCornerEdge.Vertical; } Assert.AreEqual(edgeVertical, vertical); }