Projectile2DTests ClassDelta Engine Documentation
Inheritance Hierarchy

System Object
  DeltaEngine.Platforms TestWithMocksOrVisually
    DeltaEngine.Physics2D.Tests Projectile2DTests

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

public class Projectile2DTests : TestWithMocksOrVisually

The Projectile2DTests type exposes the following members.

Constructors

  NameDescription
Public methodProjectile2DTests
Initializes a new instance of the Projectile2DTests class
Top
Methods

  NameDescription
Protected methodAdvanceTimeAndUpdateEntities (Inherited from TestWithMocksOrVisually.)
Public methodCreateProjectile
Public methodExceedingLifeTime
Public methodInitializeResolver (Inherited from TestWithMocksOrVisually.)
Public methodObjectAffixedToPhysicsBody
Protected methodRegisterMock T  (Inherited from TestWithMocksOrVisually.)
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 CreateProjectile()
{
    var bulletImpulse = new Vector2D(0.3f, 0.3f);
    const int BulletDamage = 10;
    var bullet = CreateBullet(bulletImpulse, BulletDamage);
    Assert.IsTrue(bullet.Get<PhysicsBody>().LinearVelocity.IsNearlyEqual(bulletImpulse / 1000000f));
    Assert.AreEqual(BulletDamage, bullet.Damage);
}
[Test, CloseAfterFirstFrame, Ignore]
public void ExceedingLifeTime()
{
    var exceeded = false;
    var bullet = CreateBullet(Vector2D.One, 0);
    bullet.LifeTime = 0.1f;
    bullet.OnLifeTimeExceeded += () => exceeded = true;
    AdvanceTimeAndUpdateEntities(0.4f);
    Assert.IsFalse(bullet.IsActive);
    Assert.IsTrue(exceeded);
} //ncrunch: no coverage end
[Test, CloseAfterFirstFrame]
public void ObjectAffixedToPhysicsBody()
{
    var bullet = CreateBullet(Vector2D.Zero, 0);
    var physicsBody = bullet.Get<PhysicsBody>();
    physicsBody.Position = Vector2D.One;
    physicsBody.Rotation = 10;
    AdvanceTimeAndUpdateEntities();
    Assert.AreEqual(10, bullet.Rotation);
    Assert.AreEqual(1.0f, bullet.Center.X, 0.01f);
    Assert.AreEqual(1.0f, bullet.Center.Y, 0.01f);
}
See Also