GeometryTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Graphics.Tests GeometryTests

Namespace: DeltaEngine.Graphics.Tests
Assembly: DeltaEngine.Graphics.Tests (in DeltaEngine.Graphics.Tests.dll) Version: 1.1.1.0 (1.1.1)
Syntax

public class GeometryTests : TestWithMocksOrVisually

The GeometryTests type exposes the following members.

Constructors

  NameDescription
Public methodGeometryTests
Initializes a new instance of the GeometryTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreateGeometry
Public methodCreateGeometryDataTypeFromShortAndFullNameReturnTheSameType
Public methodCreationTwoGeometriesWithSameArgumentsStillResultsInDifferentObjects
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodLoadInvalidDataThrows
Public methodLoadSimpleBoxGeometry
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
Protected methodResolve T  (Inherited from TestWithMocksOrVisually.)
Protected methodRunAfterFirstFrame (Inherited from TestWithMocksOrVisually.)
Public methodRunTestAndDisposeResolverWhenDone (Inherited from TestWithMocksOrVisually.)
Public methodSetInvalidDataThrows
Public methodShowBillboardSpriteIn3DAsSimpleTriangle
Public methodShowLineIn3D
Public methodShowSquareIn3D
Public methodShowTriangle
Top
Properties

  NameDescription
Protected propertyIsMockResolver (Inherited from TestWithMocksOrVisually.)
Top
Examples

[Test, CloseAfterFirstFrame]
public void SetInvalidDataThrows()
{
    var geometry =
        ContentLoader.Create<Geometry>(new GeometryCreationData(VertexFormat.Position3DColor, 1, 1));
    Assert.Throws<Geometry.InvalidNumberOfVertices>(
        () => geometry.SetData(new Vertex[] { }, new short[] { 0 }));
    Assert.Throws<Geometry.InvalidNumberOfIndices>(
        () => geometry.SetData(new Vertex[] { new VertexPosition3DColor(Vector3D.Zero, Color.Red) },
            new short[] { }));
}
[Test, CloseAfterFirstFrame]
public void LoadInvalidDataThrows()
{
    var creationData = new GeometryCreationData(VertexFormat.Position3DColor, 1, 1);
    var geometry = ContentLoader.Create<TestGeometry>(creationData);
    Assert.Throws<Geometry.EmptyGeometryFileGiven>(geometry.LoadInvalidData);
}
[Test, CloseAfterFirstFrame]
public void CreateGeometry()
{
    var creationData = new GeometryCreationData(VertexFormat.Position3DColor, 1, 1);
    var geometry = ContentLoader.Create<TestGeometry>(creationData);
    geometry.LoadValidData();
    Assert.AreEqual(6, geometry.NumberOfIndices);
    Assert.AreEqual(1, geometry.NumberOfVertices);
    geometry.LoadFromFile(TestGeometry.CreateValidData());
    Assert.AreEqual(6, geometry.NumberOfIndices);
    Assert.AreEqual(1, geometry.NumberOfVertices);
    Assert.AreEqual(VertexFormat.Position3DColor, geometry.Format);
}
[Test, CloseAfterFirstFrame]
public void CreationTwoGeometriesWithSameArgumentsStillResultsInDifferentObjects()
{
    var creationData1 = new GeometryCreationData(VertexFormat.Position3DColor, 1, 1);
    var creationData2 = new GeometryCreationData(VertexFormat.Position3DColor, 1, 1);
    Assert.IsFalse(creationData1.Equals(creationData2));
    var geometry1 = ContentLoader.Create<TestGeometry>(creationData1);
    var geometry2 = ContentLoader.Create<TestGeometry>(creationData2);
    Assert.AreNotEqual(geometry1, geometry2);
}
[Test, ApproveFirstFrameScreenshot]
public void ShowTriangle()
{
    CreateTriangle(new Vertex[]
    {
        new VertexPosition3DColor(new Vector3D(-3.0f, 0.0f, 0.0f), Color.Red),
        new VertexPosition3DColor(new Vector3D(3.0f, 0.0f, 0.0f), Color.Yellow),
        new VertexPosition3DColor(new Vector3D(1.5f, 3.0f, 0.0f), Color.Teal)
    });
}
[Test, ApproveFirstFrameScreenshot]
public void ShowSquareIn3D()
{
    CreateTriangle(new Vertex[]
    {
        new VertexPosition3DColor(new Vector3D(-3.0f, 3.0f, 0.0f), Color.Red),
        new VertexPosition3DColor(new Vector3D(-3.0f, -3.0f, 0.0f), Color.Red),
        new VertexPosition3DColor(new Vector3D(3.0f, -3.0f, 0.0f), Color.Red)
    });
    CreateTriangle(new Vertex[]
    {
        new VertexPosition3DColor(new Vector3D(3.0f, 3.0f, 0.0f), Color.Red),
        new VertexPosition3DColor(new Vector3D(-3.0f, 3.0f, 0.0f), Color.Red),
        new VertexPosition3DColor(new Vector3D(3.0f, -3.0f, 0.0f), Color.Red)
    });
}
[Test, ApproveFirstFrameScreenshot]
public void ShowLineIn3D()
{
    var drawing = Resolve<Drawing>();
    var lineMaterial = new Material(ShaderFlags.Colored, "");
    new MaterialVertexDrawer(
        () => drawing.AddLines(lineMaterial,
            new[]
            {
                new VertexPosition3DColor(new Vector3D(-3.0f, 3.0f, 0.0f), Color.Red),
                new VertexPosition3DColor(new Vector3D(3.0f, 3.0f, 0.0f), Color.Red)
            }));
}
[Test, ApproveFirstFrameScreenshot]
public void ShowBillboardSpriteIn3DAsSimpleTriangle()
{
    var drawing = Resolve<Drawing>();
    var billboardMaterial = new Material(ShaderFlags.Textured, "DeltaEngineLogo");
    new MaterialVertexDrawer(
        () => drawing.Add(billboardMaterial,
            new[]
            {
                new VertexPosition3DUV(new Vector3D(-3.0f, 3.0f, 0.0f), Vector2D.Zero),
                new VertexPosition3DUV(new Vector3D(-3.0f, -3.0f, 0.0f), Vector2D.UnitY),
                new VertexPosition3DUV(new Vector3D(3.0f, -3.0f, 0.0f), Vector2D.One)
            }));
}
[Test, CloseAfterFirstFrame]
public void LoadSimpleBoxGeometry()
{
    ContentLoader.Load<Geometry>("SimpleBox");
}
[Test, CloseAfterFirstFrame]
public void CreateGeometryDataTypeFromShortAndFullNameReturnTheSameType()
{
    Assert.AreEqual(
        BinaryDataExtensions.GetTypeFromShortNameOrFullNameIfNotFound("GeometryData"),
        BinaryDataExtensions.GetTypeFromShortNameOrFullNameIfNotFound(
            "DeltaEngine.Graphics.Geometry+GeometryData"));
}
See Also