示例#1
0
        public void DoesMatchCombo_ReturnsAsExpected(List <int> i_comboAttempt, bool i_expectedMatch)
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackCombo().Returns(new List <int>()
            {
                1, 2, 3
            });

            List <IGamePiece> comboAttempt = new List <IGamePiece>();

            if (i_comboAttempt != null)
            {
                foreach (int pieceType in i_comboAttempt)
                {
                    IGamePiece mockPiece = Substitute.For <IGamePiece>();
                    mockPiece.PieceType.Returns(pieceType);
                    comboAttempt.Add(mockPiece);
                }
            }

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            bool doesMatch = systemUnderTest.DoesMatchCombo(comboAttempt);

            Assert.AreEqual(i_expectedMatch, doesMatch);
        }
示例#2
0
        public void WhenCreating_StatsSetToDataValues()
        {
            List <int> mockAttackCombo = new List <int>()
            {
                1, 2, 3
            };

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

            mockData.GetDefense().Returns(10);
            mockData.GetDefenseType().Returns(2);
            mockData.GetAttackRate().Returns(1500);
            mockData.GetDamage().Returns(1000);
            mockData.GetDamageType().Returns(30);
            mockData.GetAttackCombo().Returns(mockAttackCombo);
            mockData.GetId().Returns("Blob");

            GameMonster systemUnderTest = new GameMonster(mockData);

            Assert.AreEqual(10, systemUnderTest.Defense);
            Assert.AreEqual(2, systemUnderTest.DefenseType);
            Assert.AreEqual(1500, systemUnderTest.AttackRate);
            Assert.AreEqual(1000, systemUnderTest.AttackPower);
            Assert.AreEqual(30, systemUnderTest.AttackType);
            Assert.AreEqual(mockAttackCombo, systemUnderTest.AttackCombo);
            Assert.AreEqual("Blob", systemUnderTest.Id);
        }
示例#3
0
        public void IsDead_ReturnsExpected(int i_remainingHP, bool i_isDead)
        {
            GameMonster systemUnderTest = new GameMonster(Substitute.For <IMonsterData>());

            systemUnderTest.RemainingHP = i_remainingHP;

            Assert.AreEqual(i_isDead, systemUnderTest.IsDead());
        }
示例#4
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);
        }
示例#5
0
        public void AfterTick_IfLappingCycle_CorrectNumberOfAttacksSent(long i_tick, int i_expectedAttacks)
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(1000);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(i_tick);

            MyMessenger.Instance.Received(i_expectedAttacks).Send <IGameMonster>(GameMessages.MONSTER_ATTACK, systemUnderTest);
        }
示例#6
0
        public void GetAttackProgress_ReturnsAsExpected(long i_curAttackCycle, long i_attackRate, float i_expected)
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(i_attackRate);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(i_curAttackCycle);

            Assert.AreEqual(i_expected, systemUnderTest.GetAttackProgress());
        }
示例#7
0
        public void AfterTick_IfLappingCycle_ValueIsAsExpected()
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(1000);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(2254);

            Assert.AreEqual(254, systemUnderTest.AttackCycle);
        }
示例#8
0
        public void NegativeTicks_DoNotChangeAttackCycle()
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(1000);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(-1000);

            Assert.AreEqual(0, systemUnderTest.AttackCycle);
        }
示例#9
0
        public void AfterTick_AttackCycleResetsToZero_WhenTickEqualsRate()
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(1000);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(1000);

            Assert.AreEqual(0, systemUnderTest.AttackCycle);
        }
示例#10
0
        public void AfterTick_WhenAttackIsNotCycled_ValueIsAsExpected()
        {
            IMonsterData mockMonsterData = Substitute.For <IMonsterData>();

            mockMonsterData.GetAttackRate().Returns(1000);

            GameMonster systemUnderTest = new GameMonster(mockMonsterData);

            systemUnderTest.Tick(100);

            Assert.AreEqual(100, systemUnderTest.AttackCycle);
        }
 private void SetMonsters()
 {
     Monsters = new List <IMonsterWaveData>();
     if (Data.GetMonsters() != null)
     {
         for (int i = 0; i < mData.GetNumWaves(); ++i)
         {
             IMonsterWaveData wave = new MonsterWaveData();
             foreach (string monsterId in Data.GetMonsters())
             {
                 IMonsterData monsterData = mMonsterDataManager.GetData(monsterId);
                 IGameMonster monster     = new GameMonster(monsterData);
                 wave.AddMonster(monster);
             }
             Monsters.Add(wave);
         }
     }
 }
示例#12
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);
        }
示例#13
0
        public void WhenCreating_AttackCycleIsZero()
        {
            GameMonster systemUnderTest = new GameMonster(Substitute.For <IMonsterData>());

            Assert.AreEqual(0f, systemUnderTest.AttackCycle);
        }