Polygon2DTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  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

public class Polygon2DTests : TestWithMocksOrVisually

The Polygon2DTests type exposes the following members.

Constructors

  NameDescription
Public methodPolygon2DTests
Initializes a new instance of the Polygon2DTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodChangeOutlineColor
Public methodChangePolygonAfterFirstFrame
Public methodDrawComplexPolygon
Public methodDrawFourHundredComplexPolygons
Public methodDrawTwoComplexPolygons
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodNewPolygon
Public methodNoErrorIfThereAreNoVertices
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Public methodRenderEllipseOutline
Public methodRenderingPolygonWithNoPointsDoesNotError
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
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