コード例 #1
0
        public void Attack_DecreasesEnemyHpByAttackerDamage()
        {
            int warriorInitialHp = 100;
            var attacker         = new Warrior("Attacker", 50, 100);
            var warrior          = new Warrior("Warrrior", 30, warriorInitialHp);

            attacker.Attack(warrior);

            Assert.That(warrior.HP, Is.EqualTo(warriorInitialHp - attacker.Damage));
        }
コード例 #2
0
        public void WarriorsCannotAtackOtherWarriorThatHasLessThan30Hp()
        {
            Warrior pesho = new Warrior("Pesho", 20, 50);
            Warrior gosho = new Warrior("Gosho", 15, 29);

            Assert.Throws <InvalidOperationException>(() =>
            {
                pesho.Attack(gosho);
            });
        }
コード例 #3
0
        public void TestAttackWithLowHp()
        {
            Warrior attacker = new Warrior("Pesho", 10, 25);
            Warrior defender = new Warrior("Gosho", 5, 45);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            });
        }
コード例 #4
0
ファイル: WarriorTests.cs プロジェクト: mindball/CSharpOOP
        public void AttackMethodShouldThrowInvalidOperationExceptionWhenDefenderHpIsLessOrEqual30(
            string defenderName, int defenderDamage, int defenderHp)
        {
            Warrior attacker = new Warrior("SunshineWarrion", 200, 500);

            Warrior defender = new Warrior(defenderName, defenderDamage, defenderHp);

            Assert.Throws <InvalidOperationException>(
                () => attacker.Attack(defender));
        }
コード例 #5
0
        public void WarriorsCannotAtackStrongerWarriorThanThem()
        {
            Warrior pesho = new Warrior("Pesho", 20, 50);
            Warrior gosho = new Warrior("Gosho", 1000, 50);

            Assert.Throws <InvalidOperationException>(() =>
            {
                pesho.Attack(gosho);
            });
        }
コード例 #6
0
        public void ShouldThrowInvalidOperationExceptionWhenTryToAttackEnenyWithLowThanMinHp(int defenderHp)
        {
            Warrior attacker = new Warrior("Vladi", 10, 100);
            Warrior defender = new Warrior("Oki", 10, defenderHp);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            });
        }
コード例 #7
0
        public void BothWarriorShouldTakeDamageWhenAttackEachOther()
        {
            Warrior attacker = new Warrior("Vladi", 10, 40);
            Warrior defender = new Warrior("Oki", 5, 50);

            attacker.Attack(defender);

            Assert.AreEqual(35, attacker.HP);
            Assert.AreEqual(40, defender.HP);
        }
コード例 #8
0
        public void WarriorShouldThrowExceptionWhenVictimHPAreBelowOrEqual30AndTryAttack(string name, int damage, int hp)
        {
            Warrior warrior1 = new Warrior("Tosho", 50, 40);
            Warrior warrior2 = new Warrior(name, damage, hp);

            Assert.Throws <InvalidOperationException>(() =>
            {
                warrior1.Attack(warrior2);
            });
        }
コード例 #9
0
        public void WarriorShouldThrowExceptionWhenVictimDamageAreBiggerThanHisHP(string name, int damage, int hp)
        {
            Warrior warrior1 = new Warrior("Tosho", 50, 40);
            Warrior warrior2 = new Warrior(name, damage, hp);

            Assert.Throws <InvalidOperationException>(() =>
            {
                warrior1.Attack(warrior2);
            });
        }
コード例 #10
0
        public void MethodShouldThrowInvalidOperationExceptionWhenWarriorAttackEnemyWithHpBellow30()
        {
            var name   = "Pesho";
            var damage = 30;
            var hp     = 30;

            Warrior warrior = new Warrior(name, damage, hp);

            Assert.Throws <InvalidOperationException>(() => warrior.Attack(new Warrior("Gosho", 20, 20)));
        }
コード例 #11
0
        public void MethodShouldTestTheReduceHpOfAttackedWarrior()
        {
            Warrior warrior = new Warrior("Pesho", 30, 40);
            Warrior enemy   = new Warrior("Gosho", 20, 40);

            warrior.Attack(enemy);

            var expectedHpEnemy = 10;
            var actualHpEnemy   = enemy.HP;

            Assert.AreEqual(expectedHpEnemy, actualHpEnemy);

            warrior.Attack(enemy);

            var expectedHpEnemyAfterSecondAttack = 0;
            var actualHpEnemyAfterSecondAttack   = enemy.HP;

            Assert.AreEqual(expectedHpEnemyAfterSecondAttack, actualHpEnemyAfterSecondAttack);
        }
コード例 #12
0
        public void TestHpAfterAttack()
        {
            Warrior warriorA = new Warrior("Pesho", 20, 60);
            Warrior warriorB = new Warrior("Gosho", 40, 50);

            warriorA.Attack(warriorB);

            Assert.That(warriorA.HP, Is.EqualTo(20));
            Assert.That(warriorB.HP, Is.EqualTo(30));
        }
        public void Attack_Should_Throw_Exception_When_Hp_Lower_Then_31(int hp)
        {
            Warrior myWarrior = new Warrior("Stiv", 20, hp);
            Warrior enemy     = new Warrior("Peter", 20, 40);

            Assert.Throws <InvalidOperationException>(() =>
            {
                myWarrior.Attack(enemy);
            });
        }
        public void Attack_Should_Throw_Exception_Hp_Lower_Then_Enemys_Damage()
        {
            Warrior myWarrior = new Warrior("Stiv", 100, 90);
            Warrior enemy     = new Warrior("Peter", 100, 100);

            Assert.Throws <InvalidOperationException>(() =>
            {
                myWarrior.Attack(enemy);
            });
        }
コード例 #15
0
        public void AttackShouldThrowExceptionWhenDHpBelowMinIs(int hp)
        {
            Warrior attacker = new Warrior("name", 10, 100);
            Warrior def      = new Warrior("some", 10, hp);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(def);
            }, "Enemy HP must be greater than 30 in order to attack him!");
        }
コード例 #16
0
ファイル: Game.cs プロジェクト: booch94/conquest
        static void Main(string[] args)
        {
            Human   pesho   = new Human(100, "Pesho", "Peshov", 98);
            Warrior asparuh = new Warrior(100, "Han", "Asparagus", 1000);
            Weapon  axe     = new Weapon(10, 10, 100, 5, 50, 50, 51, 1);

            asparuh.SetTarget(pesho);
            asparuh.Attack(axe);
            Console.WriteLine(asparuh.Target.Health);
        }
コード例 #17
0
        public void ShouldThrowInvalidOperationExceptionWhenHpIsTooLowAndTryToAttackOtherWarriors(int attackerHp)
        {
            Warrior attacker = new Warrior("Vladi", 10, attackerHp);
            Warrior defender = new Warrior("Oki", 10, 40);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            });
        }
コード例 #18
0
        public void AttackMethodShouldThrowExceptionIfWarriorTryAttackStrongerEnemies()
        {
            var warrior  = new Warrior("Svetlio", 100, 50);
            var opponent = new Warrior("Test", 100, 200);

            Assert.Throws <InvalidOperationException>(() =>
            {
                warrior.Attack(opponent);
            });
        }
コード例 #19
0
        public void ShouldThrowInvalidOperationExceptionWhenTryToAttackTooStrongerEnemy()
        {
            Warrior attacker = new Warrior("Vladi", 10, 35);
            Warrior defender = new Warrior("Oki", 40, 35);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            });
        }
コード例 #20
0
        public void AttackMethodShouldThrowExceptionIfWarriorTryToAttackWarriorsWhichHPbBelow30(int belowHP)
        {
            var warrior  = new Warrior("Svetlio", 100, 200);
            var opponent = new Warrior("Test", 10, belowHP);

            Assert.Throws <InvalidOperationException>(() =>
            {
                warrior.Attack(opponent);
            });
        }
コード例 #21
0
        public void WarriorShouldTakeDamageWhenAttackEnemyAndIfEnemyWarrirDieHisHpShouldBeZero()
        {
            Warrior attacker = new Warrior("Vladi", 80, 100);
            Warrior defender = new Warrior("Oki", 10, 60);

            attacker.Attack(defender);

            Assert.AreEqual(90, attacker.HP);
            Assert.AreEqual(0, defender.HP);
        }
コード例 #22
0
        public void Warrior_Attacked_Decreas_HP()
        {
            Warrior warrior = new Warrior("Gosho", 50, 52);

            warrior.Attack(new Warrior("Pesho", 40, 40));

            int hp = warrior.HP;

            Assert.AreEqual(hp, 12);
        }
コード例 #23
0
ファイル: WarriorTests.cs プロジェクト: mindball/CSharpOOP
        public void AttackMethodShouldThrowInvalidOperationExceptionWhenAttackerHpIsLessThanDeffenderAttack()
        {
            int     attackerHp       = 100;
            int     deffenderAttack  = 101;
            Warrior attackWarrior    = new Warrior("FireWarrior", 100, attackerHp);
            Warrior deffenderWarrior = new Warrior("WaterWarrior", deffenderAttack, 200);

            Assert.Throws <InvalidOperationException>(
                () => attackWarrior.Attack(deffenderWarrior));
        }
コード例 #24
0
        public void Throw_An_Exception_If_The_Health_Is_Less_Or_Equal_To_Zero_Than_The_Enemy_Damage()
        {
            // Arrange
            var warrior = new Warrior("Stavri", 100, 90);
            var enemy   = new Warrior("Ivan", 100, 100);

            // Assert
            Assert.Throws <InvalidOperationException>(
                () => warrior.Attack(enemy));
        }
コード例 #25
0
        public void WarriorShouldNotBeAbleToAtackIfHpIsLessThan30()
        {
            Warrior pesho = new Warrior("Pesho", 20, 10);
            Warrior gosho = new Warrior("Gosho", 15, 50);

            Assert.Throws <InvalidOperationException>(() =>
            {
                pesho.Attack(gosho);
            });
        }
コード例 #26
0
        public void Attack_DecreasesEnemyHpByAttackerDamage()
        {
            int     initialWarriorHp = 100;
            Warrior attacker         = new Warrior("Attacker", 50, 100);
            Warrior warrior          = new Warrior("Warrior", 50, initialWarriorHp);

            attacker.Attack(warrior);

            Assert.AreEqual(initialWarriorHp - attacker.Damage, warrior.HP);
        }
コード例 #27
0
        public void TestAttackingStrongerEnemy()
        {
            Warrior attacker = new Warrior("Pesho", 10, 35);
            Warrior defender = new Warrior("Gosho", 40, 100);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            });
        }
コード例 #28
0
        public void AttackShouldThrowExceptionWhenAHpBelowMinIs(int hp)
        {
            Warrior attacker = new Warrior("some name", 50, hp);
            Warrior defender = new Warrior("def", 10, 40);

            Assert.Throws <InvalidOperationException>(() =>
            {
                attacker.Attack(defender);
            }, "Your HP is too low in order to attack other warriors!");
        }
コード例 #29
0
        public void Attack_DecreaseHpWithAttack()
        {
            int initialHp = 100;
            var attacker  = new Warrior("Attacker", 50, initialHp);
            var warrior   = new Warrior("Warrrior", 30, 100);

            attacker.Attack(warrior);

            Assert.That(attacker.HP, Is.EqualTo(initialHp - warrior.Damage));
        }
コード例 #30
0
        public void AttackMethodWorkCorrectly()
        {
            var attackWarrior = new Warrior("ivan", 5, 50);

            warrior.Attack(attackWarrior);
            int expectionAttackWarriorHp = 40;
            int expectionWarriorHp       = 95;

            Assert.AreEqual(expectionWarriorHp, warrior.HP);
            Assert.AreEqual(expectionAttackWarriorHp, attackWarrior.HP);
        }