Inheritance Hierarchy
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
The GeometryTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
GeometryTests | Initializes a new instance of the GeometryTests class |
Methods
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
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