Inheritance Hierarchy
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
The Projectile2DTests type exposes the following members.
Constructors
Name | Description | |
---|---|---|
Projectile2DTests | Initializes a new instance of the Projectile2DTests class |
Methods
Name | Description | |
---|---|---|
AdvanceTimeAndUpdateEntities | (Inherited from TestWithMocksOrVisually.) | |
CreateProjectile | ||
ExceedingLifeTime | ||
InitializeResolver | (Inherited from TestWithMocksOrVisually.) | |
ObjectAffixedToPhysicsBody | ||
RegisterMock T | (Inherited from TestWithMocksOrVisually.) | |
Resolve T | (Inherited from TestWithMocksOrVisually.) | |
RunAfterFirstFrame | (Inherited from TestWithMocksOrVisually.) | |
RunTestAndDisposeResolverWhenDone | (Inherited from TestWithMocksOrVisually.) |
Properties
Name | Description | |
---|---|---|
IsMockResolver | (Inherited from TestWithMocksOrVisually.) |
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