Пример #1
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));
        }
Пример #2
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);
        }
Пример #3
0
        public void ChangeDamageWhenAttacking_ShouldThrowWithCorrectMessage_WhenDefenderParameterIsNull()
        {
            var attackerWithSpecialty   = new Mock <ICreaturesInBattle>();
            ICreaturesInBattle defender = null;
            var typeToHate = typeof(FakeCreature);
            var damage     = 10m;

            var hate = new Hate(typeToHate);

            var exception = Assert.Throws <ArgumentNullException>(() => hate.ChangeDamageWhenAttacking(attackerWithSpecialty.Object, defender, damage));

            StringAssert.Contains("defender", exception.Message);
        }
Пример #4
0
        public void ChangeDamageWhenAttacking_ShouldReturnDamageLargerThanInputDamage_IfDefenderTypeIsEqualToCreatureTypeToHate()
        {
            var attackerWithSpecialty = new Mock <ICreaturesInBattle>();
            var defender       = new Mock <ICreaturesInBattle>();
            var typeToHate     = typeof(FakeCreature);
            var expectedDamage = 10m;

            defender.SetupGet(mock => mock.Creature).Returns(new FakeCreature());

            var hate = new Hate(typeToHate);

            var actual = hate.ChangeDamageWhenAttacking(attackerWithSpecialty.Object, defender.Object, expectedDamage);

            Assert.IsTrue(expectedDamage < actual);
        }
Пример #5
0
        public void ChangeDamageWhenAttacking_ShouldNotModifyDamage_IfDefenderTypeIsNotEqualToCreatureTypeToHate()
        {
            var attackerWithSpecialty = new Mock <ICreaturesInBattle>();
            var defender       = new Mock <ICreaturesInBattle>();
            var typeToHate     = typeof(FakeCreature);
            var expectedDamage = 10m;

            defender.SetupGet(mock => mock.Creature).Returns(new DifferentFakeCreature());

            var hate = new Hate(typeToHate);

            var actual = hate.ChangeDamageWhenAttacking(attackerWithSpecialty.Object, defender.Object, expectedDamage);

            Assert.AreEqual(expectedDamage, actual);
        }