public void DealDamage_WhenDefenderIsNull_ShouldThrowArgumentNullException()
        {
            ICreaturesInBattle defender = null;
            var tested = new CreaturesInBattle(new AncientBehemoth(), 1);

            Assert.Throws <ArgumentNullException>(() => tested.DealDamage(defender));
        }
        public void ReturnCorrectCreature_WhenConstructed()
        {
            var ang = new Angel();

            var creatureInBattle = new CreaturesInBattle(ang, 2);

            Assert.AreEqual(ang, creatureInBattle.Creature);
        }
        public void CreaturesTotalHitPoints_WhenConstructed()
        {
            var ang = new Angel();

            var creatureInBattle = new CreaturesInBattle(ang, 2);

            Assert.AreEqual(400, creatureInBattle.TotalHitPoints);
        }
        public void Return0HitPoints_WhenTotalHitPointsIsBellow0()
        {
            var ang = new AngelMock();

            var creatureInBattle = new CreaturesInBattle(ang, 2);

            Assert.AreEqual(0, creatureInBattle.TotalHitPoints);
        }
        public void ThrowArgumentNullException_WhenApplyWhenAttackingIsCalledWithNullDefender()
        {
            var reduceEnemyDefenseByPercentage = new ReduceEnemyDefenseByPercentage(2.5m);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            Assert.Throws <ArgumentNullException>(() => reduceEnemyDefenseByPercentage.ApplyWhenAttacking(creaturesInBattle, null));
        }
        public void CreaturePermanentDefense_WhenConstructed()
        {
            var ang = new Angel();

            var creatureInBattle = new CreaturesInBattle(ang, 2);

            Assert.AreEqual(20, creatureInBattle.PermanentDefense);
        }
        public void ReturnCorrectStringFormat_WhenValidCreatureIsPassed()
        {
            var creaturesInBattle = new CreaturesInBattle(new Angel(), 2);

            var expectedStringFormat = "2 Angel (ATT:20; DEF:20; THP:400; LDMG:0)";

            Assert.AreEqual(expectedStringFormat, creaturesInBattle.ToString());
        }
示例#8
0
        public void ThrowArgumentNullException_WhenNullDefenderWithSpecialtyIsPassed()
        {
            var doubleAttackWhenAttacking = new DoubleAttackWhenAttacking(5);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            Assert.Throws <ArgumentNullException>(() =>
                                                  doubleAttackWhenAttacking.ApplyWhenAttacking(creaturesInBattle, null));
        }
        public void ThrowArgumentNullException_WhenApplyWhenDefendingIsCalledWithNullAttackerWithSpecialty()
        {
            var doubleDefenseWhenDefending = new DoubleDefenseWhenDefending(1);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            Assert.Throws <ArgumentNullException>(() =>
                                                  doubleDefenseWhenDefending.ApplyWhenDefending(creaturesInBattle, null));
        }
示例#10
0
        public void ThrowArgumentNullException_ChangeDamageWhenAttackingIsCalledWithNullDefender()
        {
            var hate = new Hate(typeof(Angel));

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            Assert.Throws <ArgumentNullException>(() =>
                                                  hate.ChangeDamageWhenAttacking(creaturesInBattle, null, 20));
        }
        public void ThrowArgumentNullException_WhenNullAttackerWithSpecialtyIsPassed()
        {
            var doubleDamage = new DoubleDamage(5);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            Assert.Throws <ArgumentNullException>(() =>
                                                  doubleDamage.ChangeDamageWhenAttacking(null, creaturesInBattle, 20));
        }
        public void AddCorrectPermanentDeffenseBonus_WhenSkipCommandIsCalled()
        {
            var ang = new Angel();

            var creatureInBattle = new CreaturesInBattle(ang, 1);

            creatureInBattle.Skip();

            Assert.AreEqual(23, creatureInBattle.PermanentDefense);
        }
示例#13
0
        public void ReturnCorrectDamage_ChangeDamageWhenAttackingIsCalledWithoutHatedType()
        {
            var hate = new Hate(typeof(Devil));

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            var result = hate.ChangeDamageWhenAttacking(creaturesInBattle, creaturesInBattle, 10);

            Assert.AreEqual(10, result);
        }
        public void ReturnCorrectDefenseChanges_WhenApplyWhenAttackingIsCalled()
        {
            var reduceEnemyDefenseByPercentage = new ReduceEnemyDefenseByPercentage(10m);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            reduceEnemyDefenseByPercentage.ApplyWhenAttacking(creaturesInBattle, creaturesInBattle);

            Assert.AreEqual(18, creaturesInBattle.CurrentDefense);
        }
        public void ReturnCorrectMultipliedDefense_WhenApplyWhenDefendingIsCalled()
        {
            var doubleDefenseWhenDefending = new DoubleDefenseWhenDefending(1);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            doubleDefenseWhenDefending.ApplyWhenDefending(creaturesInBattle, creaturesInBattle);

            Assert.AreEqual(40, creaturesInBattle.CurrentDefense);
        }
示例#16
0
        public void AddCorrectCurrentAttackBonus_WhenRoundsAreAbove0()
        {
            var doubleAttackWhenAttacking = new DoubleAttackWhenAttacking(5);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            doubleAttackWhenAttacking.ApplyWhenAttacking(creaturesInBattle, creaturesInBattle);

            Assert.AreEqual(40, creaturesInBattle.CurrentAttack);
        }
示例#17
0
        public void ReturnCorrectPermanentDefense_WhenApplyOnSkipIsCalled()
        {
            var defenceWhenSkip = new AddDefenseWhenSkip(2);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            defenceWhenSkip.ApplyOnSkip(creaturesInBattle);

            Assert.AreEqual(22, creaturesInBattle.PermanentDefense);
        }
        public void ReturnCorrectDamage_ChangeDamageWhenAttackingIsCalledWithoutHatedType()
        {
            var specialty = new SpecialityMock();

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            var result = specialty.ChangeDamageWhenAttacking(creaturesInBattle, creaturesInBattle, 10);

            Assert.AreEqual(10, result);
        }
        public void ReturnCorrectDefenderHitPoints_WhenDefenceIsNotHighterThanDamage()
        {
            var attackerInBattle = new CreaturesInBattle(new Angel(), 1);
            var defenderInBattle = new CreaturesInBattle(new Angel(), 1);

            var angelHitPointsAfterAngelAttack = 200 - 50;

            attackerInBattle.DealDamage(defenderInBattle);

            Assert.AreEqual(angelHitPointsAfterAngelAttack, defenderInBattle.TotalHitPoints);
        }
        public void DealDamage_WhenDefenderHasLargerDefence_ShouldReturnExpectedResult()
        {
            var defender = new CreaturesInBattle(new Behemoth(), 1);
            var attacker = new CreaturesInBattle(new AncientBehemoth(), 1);

            attacker.DealDamage(defender);

            var result = defender.TotalHitPoints;

            Assert.AreEqual(116, result);
        }
示例#21
0
        public void ResetToPermanentAttack_WhenRoundsGoBellow1()
        {
            var doubleAttackWhenAttacking = new DoubleAttackWhenAttacking(1);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            doubleAttackWhenAttacking.ApplyWhenAttacking(creaturesInBattle, creaturesInBattle);
            doubleAttackWhenAttacking.ApplyWhenAttacking(creaturesInBattle, creaturesInBattle);

            Assert.AreEqual(40, creaturesInBattle.CurrentAttack);
        }
        public void DealDamage_WhenDefenderIsValid_ShouldReturnExpectedResult()
        {
            var defender = new CreaturesInBattle(new Behemoth(), 2);
            var attacker = new CreaturesInBattle(new Behemoth(), 1);

            attacker.DealDamage(defender);

            var result = defender.TotalHitPoints;

            Assert.AreEqual(280, result);
        }
        public void ResetCurrentDefense_WhenApplyWhenDefendingRoundsGetTo0()
        {
            var doubleDefenseWhenDefending = new DoubleDefenseWhenDefending(2);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            doubleDefenseWhenDefending.ApplyWhenDefending(creaturesInBattle, creaturesInBattle);
            doubleDefenseWhenDefending.ApplyWhenDefending(creaturesInBattle, creaturesInBattle);
            doubleDefenseWhenDefending.ApplyWhenDefending(creaturesInBattle, creaturesInBattle);

            Assert.AreEqual(80, creaturesInBattle.CurrentDefense);
        }
示例#24
0
        public override void AddCreatures(CreatureIdentifier creatureIdentifier, int count)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            var creature          = this.CreaturesFactory.CreateCreature(creatureIdentifier.CreatureType);
            var creaturesInBattle = new CreaturesInBattle(creature, count);

            this.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);
        }
示例#25
0
        public void AddCorrectValue_SkipCreatureIsPassed()
        {
            var attackWhenSkip = new AddAttackWhenSkip(9);

            var creature = new Angel();

            var creaturesInBattle = new CreaturesInBattle(creature, 1);

            attackWhenSkip.ApplyOnSkip(creaturesInBattle);

            Assert.AreEqual(29, creaturesInBattle.PermanentAttack);
        }
示例#26
0
        public void ReturnCorrectTotalHitPoints_WhenApplyAfterDefendingIsCalled()
        {
            var resurrection = new Resurrection();

            var angel = new Angel();

            var creaturesInBattle = new CreaturesInBattle(angel, 1);

            resurrection.ApplyAfterDefending(creaturesInBattle);

            Assert.AreEqual(200, creaturesInBattle.TotalHitPoints);
        }
        public void Skip_ShouldCallApplyOnSkipForEachSpecialty()
        {
            var mockedCreature    = new MockedCreature(1, 1, 10, 1M);
            var creaturesInBattle = new CreaturesInBattle(mockedCreature, 1);

            creaturesInBattle.Skip();

            foreach (var speciality in mockedCreature.Specialties)
            {
                speciality.Verify(x => x.ApplyOnSkip(It.IsAny <ICreaturesInBattle>()), Times.Once);
            }
        }
        public void ResetToCurrentDamage_WhenRoundsGoBellow1()
        {
            var doubleDamage = new DoubleDamage(1);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            var currentDamage = 2;

            doubleDamage.ChangeDamageWhenAttacking(creaturesInBattle, creaturesInBattle, currentDamage);
            var result = doubleDamage.ChangeDamageWhenAttacking(creaturesInBattle, creaturesInBattle, currentDamage);

            Assert.AreEqual(2, result);
        }
        public void CallWriteLineExactly2Times_WhenValidValueIsPassed()
        {
            var loggerMock  = new Mock <ILogger>();
            var factoryMock = new Mock <ICreaturesFactory>();

            loggerMock.Setup(x => x.WriteLine(It.IsAny <string>()));

            var battleManager = new MockedBattleManager(factoryMock.Object, loggerMock.Object);

            var creaturesInBattle = new CreaturesInBattle(new Angel(), 1);

            var identifier = CreatureIdentifier.CreatureIdentifierFromString("Angel(1)");

            battleManager.FirstArmyCreatures.Add(creaturesInBattle);

            battleManager.Skip(identifier);

            loggerMock.Verify(x => x.WriteLine(It.IsAny <string>()), Times.Exactly(2));
        }
示例#30
0
        public void AddCreatures(CreatureIdentifier creatureIdentifier, int count)
        {
            if (creatureIdentifier == null)
            {
                throw new ArgumentNullException("creatureIdentifier");
            }

            var creature          = this.creaturesFactory.CreateCreature(creatureIdentifier.CreatureType);
            var creaturesInBattle = new CreaturesInBattle(creature, count);

            this.AddCreaturesByIdentifier(creatureIdentifier, creaturesInBattle);

            this.logger.WriteLine(
                string.Format(
                    CultureInfo.InvariantCulture,
                    LogFormat,
                    string.Format(CultureInfo.InvariantCulture, "Creature added to army {0}", creatureIdentifier.ArmyNumber),
                    creature));
        }