Inheritance Hierarchy
DeltaEngine.Platforms TestWithMocksOrVisually
DeltaEngine.Rendering2D.Shapes.Tests Polygon2DTests
Namespace: DeltaEngine.Rendering2D.Shapes.Tests
Assembly: DeltaEngine.Rendering2D.Shapes.Tests (in DeltaEngine.Rendering2D.Shapes.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax
The Polygon2DTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Polygon2DTests | Initializes a new instance of the Polygon2DTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
ChangeOutlineColor | ||
ChangePolygonAfterFirstFrame | ||
DrawComplexPolygon | ||
DrawFourHundredComplexPolygons | ||
DrawTwoComplexPolygons | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
NewPolygon | ||
NoErrorIfThereAreNoVertices | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
RenderEllipseOutline | ||
RenderingPolygonWithNoPointsDoesNotError | ||
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
Examples
[Test, CloseAfterFirstFrame] public void NewPolygon() { var polygon = new Polygon2D(Rectangle.One, Color.White); polygon.Points.AddRange(new[] { Vector2D.Zero, Vector2D.One, Vector2D.UnitY });
[Test, CloseAfterFirstFrame] public void ChangePolygonAfterFirstFrame() { var polygon = new Polygon2D(Rectangle.One, Color.White); polygon.Points.AddRange(new[] { Vector2D.Zero, Vector2D.One, Vector2D.UnitY });
[Test, CloseAfterFirstFrame] public void ChangeOutlineColor() { var polygon = new Polygon2D(Rectangle.One, Color.Red); polygon.Add(new OutlineColor(Color.Blue)); Assert.AreEqual(Color.Blue, polygon.Get<OutlineColor>().Value); }
[Test, ApproveFirstFrameScreenshot] public void RenderEllipseOutline() { var ellipse = new Ellipse(Vector2D.Half, 0.4f, 0.2f, Color.Blue); ellipse.Add(new OutlineColor(Color.Red)); ellipse.OnDraw<DrawPolygon2DOutlines>(); }
[Test, CloseAfterFirstFrame] public void RenderingPolygonWithNoPointsDoesNotError() { var ellipse = new Ellipse(Vector2D.Half, 0.4f, 0.2f, Color.Blue); var points = ellipse.Get<List<Vector2D>>(); points.Clear(); ellipse.Remove<Ellipse.UpdatePointsIfRadiusChanges>(); ellipse.Add(new OutlineColor(Color.Red)); ellipse.OnDraw<DrawPolygon2DOutlines>(); }
[Test] public void NoErrorIfThereAreNoVertices() { var entity = new Entity2D(Rectangle.One); entity.Add(new OutlineColor(Color.Red)); Assert.DoesNotThrow(entity.OnDraw<DrawPolygon2DOutlines>); }
[Test, ApproveFirstFrameScreenshot] public void DrawComplexPolygon() { CreatePolygon(Vector2D.Half, 0.25f, Color.White); }
[Test, ApproveFirstFrameScreenshot] public void DrawTwoComplexPolygons() { CreatePolygon(new Vector2D(0.25f, 0.5f), 0.2f, Color.Green); CreatePolygon(new Vector2D(0.75f, 0.5f), 0.2f, Color.Red); }
[Test, Category("Slow")] public void DrawFourHundredComplexPolygons() { // 20*20=400 * 500 polygons each is 200000 polygons (needs to be rendered in batches) for (int y = 0; y < 20; y++) for (int x = 0; x < 20; x++) CreatePolygon(new Vector2D(0.025f, 0.025f) + new Vector2D(x / 20.0f, y / 20.0f), 0.025f, Color.GetRandomColor()); }
See Also