コード例 #1
0
        public void WhenCreating_RemainingHP_EqualsMaxHP()
        {
            IMonsterData mockData = Substitute.For <IMonsterData>();

            mockData.GetMaxHP().Returns(101);

            GameMonster systemUnderTest = new GameMonster(mockData);

            Assert.AreEqual(101, systemUnderTest.RemainingHP);
        }
コード例 #2
0
ファイル: GameMonster.cs プロジェクト: jlavoine/CrossMonsters
 private void SetStats(IMonsterData i_data)
 {
     RemainingHP = i_data.GetMaxHP();
     Defense     = i_data.GetDefense();
     DefenseType = i_data.GetDefenseType();
     AttackPower = i_data.GetDamage();
     AttackType  = i_data.GetDamageType();
     AttackRate  = i_data.GetAttackRate();
     AttackCombo = i_data.GetAttackCombo();
     Id          = i_data.GetId();
 }
コード例 #3
0
        public void WhenAttackedByPlayer_ExpectedDamageRemovedFromRemainingHP(int i_playerAttackPower, int i_monsterDefense, int i_expectedDamage)
        {
            IGamePlayer mockPlayer = Substitute.For <IGamePlayer>();

            mockPlayer.GetAttackPowerForType(Arg.Any <int>()).Returns(i_playerAttackPower);

            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetMaxHP().Returns(100);
            mockMonsterData.GetDefense().Returns(i_monsterDefense);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.AttackedByPlayer(mockPlayer);

            int expectedHP = 100 - i_expectedDamage;

            Assert.AreEqual(expectedHP, systemUnderTest.RemainingHP);
        }