public void TestSpawnedTypeFirst() { FixedSpawn fixedSpawn = new FixedSpawn(); GameObjectStub gameObject = new GameObjectStub(); fixedSpawn.Spawn(gameObject); Assert.AreEqual(0, fixedSpawn.getCurrentType()); }
public void TestWithNullContainer() { IAdapter adapter = new ObstacleAdapter(null); GameObjectStub stub = new GameObjectStub(); adapter.SetFields(stub); }
public void TestWithBadAdapterContainer() { AdapterContainer adapterContainer = new AdapterContainer(); adapterContainer.SetGameObject(null); IAdapter adapter = new ObstacleAdapter(adapterContainer); GameObjectStub stub = new GameObjectStub(); adapter.SetFields(stub); }
public void TestInstantiateAndDestroy() { GameLevel gameLevel = GameState.Instance.gameLevel; GameObjectStub gameObject = new GameObjectStub(); GameObject.Instantiate(gameObject); gameLevel.Update(0); Assert.AreEqual(1, GameState.Instance.gameLevel.Find <GameObjectStub>().Count); gameObject.Destroy(); gameLevel.Update(0); Assert.AreEqual(0, GameState.Instance.gameLevel.Find <GameObjectStub>().Count); }
public void TestRandomnessOfPowerUp() { FixedSpawn fixedSpawn = new FixedSpawn(); GameObjectStub gameObject = new GameObjectStub(); int timesOfPermamentPowerup = 0; for (int i = 0; i < 1000; i++) { var powerUp = fixedSpawn.Spawn(gameObject); if (powerUp.GetType() == typeof(PermanentAttack) || powerUp.GetType() == typeof(PermanentDefense) || powerUp.GetType() == typeof(PermanentHealth) || powerUp.GetType() == typeof(PermanentSpeed)) { timesOfPermamentPowerup++; } } Assert.IsTrue(timesOfPermamentPowerup >= 450 && timesOfPermamentPowerup <= 550); }
public void TestGameObjectInstantiateAndDestroyWithParent() { GameLevel gameLevel = GameState.Instance.gameLevel; GameObjectStub parent = new GameObjectStub(); GameObjectStub child = new GameObjectStub(); GameObject.Instantiate(parent); GameObject.Instantiate(child, parent); gameLevel.Update(0); Assert.AreEqual(2, GameState.Instance.gameLevel.Find <GameObjectStub>().Count); parent.Destroy(); gameLevel.Update(0); Assert.AreEqual(0, GameState.Instance.gameLevel.Find <GameObjectStub>().Count); }
public void TestGameObjectTransform() { GameObjectStub parent = new GameObjectStub(); GameObjectStub child = new GameObjectStub(); GameObject.Instantiate(child, parent); parent.transform.position = Vector2.One; Assert.AreEqual(Vector2.One, child.transform.WorldPosition); parent.transform.rotation = 180; child.transform.position = Vector2.One; Assert.AreEqual(Vector2.Zero, child.transform.WorldPosition); child.transform.WorldPosition = -Vector2.One; Assert.AreEqual(Vector2.Zero, child.transform.position); child.transform.WorldRotation = 0; Assert.AreEqual(-180, child.transform.rotation); }