HierarchyObjectTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Tests.Entities HierarchyObjectTests

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

public class HierarchyObjectTests

The HierarchyObjectTests type exposes the following members.

Constructors

  NameDescription
Public methodHierarchyObjectTests
Initializes a new instance of the HierarchyObjectTests class
Top
Methods

  NameDescription
Public methodAddChildrenToHierarchyObject
Public methodChangeHierarchyObjectPosition
Public methodChangeHierarchyObjectRotation
Public methodChangePropertiesToObjectsWithChildren
Public methodCreateHierarchyObjectWithPosition
Public methodCreateHierarchyObjectWithRotation
Public methodInitializeEntitiesRunner
Public methodModifyPropertiesAlsoModifiesChildsHierarchy
Public methodRemoveChildren
Top
Examples

[Test]
public void CreateHierarchyObjectWithPosition()
{
    var unitXHierarchyObject = new SimpleHierarchyObject3D(Vector3D.UnitX);
    Assert.AreEqual(Vector3D.UnitX, unitXHierarchyObject.Position);
}
[Test]
public void ChangeHierarchyObjectPosition()
{
    hierarchyObject3D.Position = new Vector3D(1.0f, 1.0f, 1.0f);
    Assert.AreEqual(Vector3D.One, hierarchyObject3D.Position);
}
[Test]
public void CreateHierarchyObjectWithRotation()
{
    var axis = Vector3D.UnitY;
    const float Angle = 180.0f;
    var unitXHierarchyObject = new SimpleHierarchyObject3D
    {
        Orientation = Quaternion.FromAxisAngle(axis, Angle)
    };
    Assert.AreEqual(Vector3D.UnitY, unitXHierarchyObject.Orientation.Vector3D);
}
[Test]
public void ChangeHierarchyObjectRotation()
{
    var axis = Vector3D.UnitX;
    const float Angle = 90.0f;
    float invSqr2 = MathExtensions.InvSqrt(2);
    hierarchyObject3D.Orientation = Quaternion.FromAxisAngle(axis, Angle);
    Assert.AreEqual(new Vector3D(invSqr2, 0, 0), hierarchyObject3D.Orientation.Vector3D);
}
[Test]
public void AddChildrenToHierarchyObject()
{
    Assert.AreEqual(1, hierarchyObject3D.Children.Count);
    hierarchyObject3D.Add(new SimpleHierarchyObject3D());
    Assert.AreEqual(2, hierarchyObject3D.Children.Count);
    hierarchyObject3D.Children[0].Add(new SimpleHierarchyObject3D());
}
[Test]
public void RemoveChildren()
{
    Assert.AreEqual(1, hierarchyObject3D.Children.Count);
    hierarchyObject3D.Remove(hierarchyObject3D.Children[0]);
    Assert.AreEqual(0, hierarchyObject3D.Children.Count);
    hierarchyObject3D.UpdateGlobalsFromParent(null);
}
[Test]
public void ModifyPropertiesAlsoModifiesChildsHierarchy()
{
    hierarchyObject3D.Children[0].Add(new SimpleHierarchyObject3D());
    hierarchyObject3D.Position = Vector3D.One;
    Assert.AreEqual(hierarchyObject3D.Children[0].Children[0].Position, Vector3D.One);
}
[Test]
public void ChangePropertiesToObjectsWithChildren()
{
    hierarchyObject3D.Position = new Vector3D(1.0f, 1.0f, 1.0f);
    Assert.AreEqual(Vector3D.One, hierarchyObject3D.Children[0].Position);
    hierarchyObject3D.Orientation = Quaternion.FromAxisAngle(Vector3D.UnitY, 180.0f);
    Assert.AreEqual(Vector3D.UnitY, hierarchyObject3D.Children[0].Orientation.Vector3D);
}
See Also