Vector3DTests Create Method Delta Engine Documentation

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

public void Create()
Examples

[Test]
public void Create()
{
    const float X = 3.51f;
    const float Y = 0.23f;
    const float Z = 0.95f;
    var v = new Vector3D(X, Y, Z);
    Assert.AreEqual(v.X, X);
    Assert.AreEqual(v.Y, Y);
    Assert.AreEqual(v.Z, Z);
}
[Test]
public void CreateFromVector2D()
{
    var v = new Vector3D(new Vector2D(1, 2));
    Assert.AreEqual(1, v.X);
    Assert.AreEqual(2, v.Y);
    Assert.AreEqual(0, v.Z);
}
[Test]
public void CreateFromString()
{
    var v = new Vector3D("2.3, 1.5, 0.9");
    Assert.AreEqual(v.X, 2.3f);
    Assert.AreEqual(v.Y, 1.5f);
    Assert.AreEqual(v.Z, 0.9f);
    Assert.Throws<Vector3D.InvalidNumberOfComponents>(() => new Vector3D("2.3"));
    Assert.Throws<FormatException>(() => new Vector3D("a, b, c"));
}
See Also