private void EnemyCrushed(MonsterCrushed monsterCrushed) { var doesMonsterScore = monsterCrushed.Monster.Properties.Get(GameObjectProperties.MonsterScoresWhenKilled); if (!doesMonsterScore) { return; } var increaseToScore = ((monsterCrushed.Monster.Energy >> 1) + 1) << 1; this._score += increaseToScore; }
public void TestEnemyCrushedWhenEnemyDoesNotScore() { var propertyBag = new PropertyBag(); propertyBag.Set(GameObjectProperties.MonsterScoresWhenKilled, false); var monster = new Mock<IMonster>(); monster.Setup(monsterShoots => monsterShoots.Energy).Returns(10); monster.Setup(m => m.Properties).Returns(propertyBag); var boulder = new Mock<IGameObject>(); using (var scoreKeeper = new ScoreKeeper()) { var monsterCrushed = new MonsterCrushed(monster.Object, boulder.Object); Messenger.Default.Send(monsterCrushed); Assert.AreEqual(0, scoreKeeper.CurrentScore); } }